How to deploy React app on heroku

Deployment of React Application on Heroku is very simple task. We can deploy React app on Heroku by many ways like Heroku CLI and Github.

Before deployement process we need to sure that our application should be in a production deployment mode.

Suppose we have created the build folder for production deployment. If still you have not created the build or deployment folder then we can create it by following cammands.

If you are using webpack then npm run build is the command for create the build files. We need to deploy only these build files to run our reat app with any backend server like express, hapi and other web servers.

If your application structure is like below format after create the build files.


To deploy the React application we need a web server like express js.

So we need to install a express js framework to deploy the react app.

Create a package.json and server.js file to with express js framework.



	const express = require('express'); 
	const app = express(); 
	const path = require('path');  
	app.use(express.static(__dirname + '/build'));  
	app.listen(process.env.PORT || 8080);  
	app.get('/*', function(req, res){   
		res.sendFile(path.join(__dirname + '/build/index.html')); 
	console.log('Server listening'); 

Now upload all these files on Github or use Heroku CLI to deploy directly. Here we will use git to upload all the files on github


Then we can deploy our React app with heroku. We need Heroku account and need to create our app with Heroku.

How To Use Server-Sent Events …

How To Use Server-Sent Events in Node.js to Build a Realtime App. Server-Sent Events (SSE) is a technology based on HTTP. On the client-side, it provides an API called EventSource (part of the HTML5 standard) that allows us to connect to the server a …

read more

How To Use node-cron to Run Sc …

How To Use node-cron to Run Scheduled Jobs in Node.js . cron provides a way to repeat a task at a specific time interval. There may be repetitive tasks such as logging and performing backups that need to occur on a daily or weekly basis.One method fo …

read more