NPM version: 3.10.9
[email protected]
node: 7.0.0
Unable to add custom environment variables. Re: documentation
.env
file with variables defined as:FOO=bar
process.env.FOO
process.env.FOO
is undefined.
MacOS 10.11.6
Chrome Version 54.0.2840.71 (64-bit)
If there are additional usage steps, I suggest that they be explicitly called out in the create-react-app docs rather than linking to dot-env.
Hi @barcher , there is no additional steps. However, only env start with REACT_APP_
is available in the app, as noted in the section above your link https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-custom-environment-variables
Thanks @dvkndn! Perhaps as part of your documentation, you could discuss why you made the decision to prefix environment variables in this way? Closing.
@barcher just to be clear first, I'm not even here when we choose the 'REACT_APP' prefix, so I can't sure why.
Anyway, for me, it is really make sense to just add those which have 'REACT_APP_' prefix to our app. The advantages are similar with why you need to namespace your variables. For example, there are tons of things in process.env
, and the prefix helps you avoid accidentally override one of them. Moreover, your env
can also be used in multiple places rather than just in your react app, therefore it is good to make it clear which one is used in the react app.
Again, this is just my opinion 馃槃
Most helpful comment
Hi @barcher , there is no additional steps. However, only env start with
REACT_APP_
is available in the app, as noted in the section above your link https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-custom-environment-variables