Deploy a React application to Heroku

Deploying the example React App to Heroku is performed using Git commands. After setting up on Heroku, you add Heroku as a remote in your git config.

$ git remote add heroku git@heroku.com:your-heroku-app-name.git

Git requires an SSH Key for secure communication with Heroku (see my article on Setup MacBook for node development). Deployment is then a push command. When Heroku receives the Git push command, it installs the application.

$ git push heroku master

After the website has installed, Heroku will run the postInstall command in the package.json file, which in our case will perform a Webpack production build to output minified assets.

"dist": "webpack -p",
"postinstall": "npm run dist",

Deployment to Heroku closes the loop in our JavaScript build pipeline and demonstrates how our foundation tools (Git, node.js) are leveraged by the Heroku cloud platform to provide a production environment for our application.

See the example React App running on Heroku.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s