Skip to content

Instantly share code, notes, and snippets.

@pedrouid
Last active January 29, 2019 16:39
Show Gist options
  • Select an option

  • Save pedrouid/4faa9492f6839795f1462df443a6b282 to your computer and use it in GitHub Desktop.

Select an option

Save pedrouid/4faa9492f6839795f1462df443a6b282 to your computer and use it in GitHub Desktop.
Display package.json version on React app (using environment variables)

Display package.json version on React app

  1. Create .env file on the root directory
REACT_APP_VERSION=$npm_package_version
  1. Access from environment variables on React app
const version = process.env.REACT_APP_VERSION

Note: React only makes accessible environment variables that are prefixed with REACT_APP_

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment