Skip to content

Instantly share code, notes, and snippets.

@rogerwschmidt
Last active January 4, 2019 22:36
Show Gist options
  • Save rogerwschmidt/73623ad168aaa7493f9f4a3e20e7348d to your computer and use it in GitHub Desktop.
Save rogerwschmidt/73623ad168aaa7493f9f4a3e20e7348d to your computer and use it in GitHub Desktop.

React Deployment Instructor Notes

Objectives

  • Add a build pack to a heroku project
  • Add environment variables

How do you add a react build back to a heroku project

  • Create a new react application
  • Create a heroku project with a react build pack
heroku create --buildpack https://github.com/mars/create-react-app-buildpack.git
  • Run npm i
  • Delete yarn.lock
  • Commit all changes
  • Deploy to heroku git push heroku master
  • Visit deployed site

How do you add environment variables

  • Add environment variables
echo "REACT_APP_MESSAGE=Hello from development" > .env.development
echo "REACT_APP_MESSAGE=Hello from production" > .env.production
  • Environment variables MUST start with REACT_APP_
  • What other information can you store in enviroment variables?
  • Access enviroment variables from React process.env.REACT_APP_MESSAGE
  • Commit changes and deploy to heroku
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment