The documentation discusses how to declare these variables:
This can be done using two ways: either in your shell or in a .env file. Both of these ways are described in the next few sections.
Through the local environment
The first way is to add it to your local environment:
For instance, if you're using bash, edit ~/.bashrc
Add export REACT_APP_EDITOR=atom
to the bottom then restart your terminal (or source ~/.bashrc
)
Through .env files in your application
The second way is to create a .env
file at the root of your application directory, and add the variable on a single line there:
REACT_APP_EDITOR=atom
From the documentation, these types of files can be declared and will be consumed by Create-React-App:
.env
: Default.
.env.local
: Local overrides. This file is loaded
for all environments except test.
.env.development
, .env.test
, .env.production
: Environment-specific
settings.
.env.development.local
, .env.test.local
, .env.production.local
: Local
overrides of environment-specific settings.