Environment Variables
Set environment variables
- Source: CreateReactApp Docs
- Set env variables in format
REACT_APP_ENV_NAME
- Access in javascript as below
App.js
console.log(process.env.REACT_APP_ENV_NAME)
Read default variables
- Use different API for development and production modes
config.js
if(process.env.NODE_ENV =="production"){
// use remote API
}else{
// use local API
}