React

Article by:
Date Published:
Last Modified:

Overview

The React logo.

The React logo.

Injecting Variables At Build Time

React recognizes either environment variables or variables defined in a .env file located at the project root. React only recognizes variables which begin with REACT_APP_

1
export REACT_APP_SERVER_URL="www.myserver.com/api"

Environment variables take precedence over those defined in the .env file.

Imported variables are available in the React environment under process.env:

1
2
console.log(process.env.REACT_APP_SERVER_URL)
// stdout: www.myserver.com/api

Authors

Geoffrey Hunter

Dude making stuff.

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License .

Related Content:

Tags

comments powered by Disqus