How to deploy React.js App on Heroku

It’s super easy !!!

Image for post
Image for post
  • Step 1: Install dependencies

You will be needing the following packages

npm i express dotenv
  • Step 2: Create a server file in Project Folder

Inside your project folder, create a file named “server.js” and copy the following contents inside it.

const path = require('path');
  • Step 3: Push to GitHub

Add git add all your files, commit them and push them to GitHub, we will deploy the automatically from their

  • Step 4: on Heroku
  1. Create a new App
  2. In deploy section, connect your GitHub account :
Image for post
Image for post

and select the repository containing your react project

3. In settings, configure your environment variables, if you have them.

Image for post
Image for post

4. Deploy setting :

you can keep automatic deploy setting ON on Heroku if you want, but it’s better to return it off because free tier gives u only 5 builds and if you git push more than 5 times, 6th time you won’t be able to deploy your project. Better keep it off.

Image for post
Image for post

Then just click deploy and

That’s it, you are DONE !!!


I hope you were successful :

Follow me on


LinkedIn :

Sophomore && CSE Undergrad

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store