Reputation: 9095
using variable inside .env file. In create react app.
I am trying to re use the env variable in other env variables, is this correct of way of doing, but i am not getting the value .
.env
A=hello
B=${A}/new
Upvotes: 2
Views: 1556
Reputation: 1586
It's important to realize that env variables are only available in node environment and not in the browser.
But if you're using create-react-app
, It does some tricks for you and simulates the same behavior inside the browser, only if you put the REACT_APP_
prefix before your env variables.
As the create-react-app
docs says here:
Note: You must create custom environment variables beginning with REACT_APP_. Any other variables except NODE_ENV will be ignored to avoid accidentally exposing a private key on the machine that could have the same name. Changing any environment variables will require you to restart the development server if it is running.
Upvotes: 2