How To Run React Front-end + Express Back-end Concurrently
Read about how to run React and Express NodeJS concurrently in 3 minutes
Generally, in order to run your React app with your Node Express API back-end on your localhost server, you would usually need to run commands like npm start
for both the front-end and the back-end.
For instance, this is what our project directory would look like:
To start your Backend API server:
cd server
nodemon app.js
To run your React server:
cd client
npm start
So imagine in this scenario, we will have to kick start both the front-end and the back-end server using two terminals. Quite annoying don’t you think?
What if, we could run both the server, concurrently?
Navigate to your server
folder, and install the Node package, “concurrently”
cd server
npm install concurrently --save
Once concurrently is installed, navigate to the server
folder, and paste the code below into the package.json
. Please mind the comma at the very end of the curly bracket.