Skip to main content

Product CRUD project: React Express & Mysql

From this article, you learn React by an example project. We are going to create a simple product page that allow loggined user to manage add, list, update, delete, and search products. React is used for front-end and Express will be our backend. We create APIs to work with Mysql database using Express. Express is a minimal and fast Node.js web application framework that provides a robust set of features for web and mobile applications.

You have to create a folder called prod_project in drive D or in another drive of your choice.
From VSC editor, open the prod_project folder and on terminal change to the folder and issue the following command to create package.json file for the Express project.

D:\prod_project>npm init

Then, you go further to install Express framework by the command as below:

D:\prod_project>npm install express

To work with Mysql database on your Windows machine, you install Mysql database server. On my machine, i have xampp package that comes with Mysql database, Apache, and PHPMyAdmin to manage Mysql databases.

Comments

Popular posts from this blog

Get start with React

To start web development with React, i recommend you install Node. Node comes with NPM (package manager) helps you easy to add dependencies, create, start, and build your React apps. You can download and install NPM from its official web site: Download NPM . Another useful tool for coder is Visual Studio Code . On my Windows machine, i have installed Node version 16.10.0 with NPM 7.14.0. Now create a project folder and name it react_tutorials in Drive D: or other drive of your choice. Then open the folder in Visual Studio COde (VSC). From the VSC editor, select Terminal. In the terminal, enter the following command to create my-app app in the project folder created above. D:\react_tutorials>npm init react-app my-app After the my-app app is created successfully. You change to my-app folder (cd my-app) . Then You run " npm start " command to start your first react app on browser. React automatically starts on port 3000.

Why React?

React is one of the top UI development frameworks. It is very popular today among web developers around the globe. I love React because of the following things: - It is simple to learn and use. - It is JavaScript library. - It effectively applies changes to a web page without reloading the page while data changed. - It is easy to find problems or errors while you are coding.

React Express & Mysql: Sequelize

Now, you have React project in my-app folder and Express project in prod_project folder. We are going to create back-end APIs that will be accessed by our React app. If you don't have React and Express apps set up, you go to the page Product CRUD Project In the prod_project folder, run the following command to install dependencies that are required to create the APIs on Express server. D:\prod_project> npm install sequelize sequelize-cli mysql2 jsonwebtoken cors body-parser bcrypt sequelize helps us synchronize the models (defined later in our project) with Mysql database. From the models, you can create tables in the database, query, add, update, delete data in the tables. sequelize-cli - Sequelize Command Line Interface helps us create models, migrations, and database. mysql2   is a fast mysql driver to work with mysql database from Express. jsonwebtoken works in user authentication by token for securely transmitting data between our back-end Express and front-end...