Accepted answer

Your app was made with create-react-app. Here are the docs for adding / referencing environment variables:

Create a file in the root folder called .env with the contents:


Then access this variable in your JavaScript via:



Dont sure, if it actual for you, CNDyson, but I think it might be helpful for newers like me:

  1. npm install --save dotenv
  2. create .env file in the root directory
  3. declare there REACT_APP_**VARIABLE_NAME** = dont forget about REACT_APP
  4. use it like this: process.env.REACT_APP_**VARIABLE_NAME**

Highly recommend to explore these links: -official documentaion - dotenv


The problem is that usually you want to access the environments variables present on the server that host your application.

With the described solution you will never be able to do docker run --env FOO="value of foo" my-org/my-app then access FOO in the app like process.env["FOO"].

create-react-app bundle the environment variables that are defined when you run yarn build.

If you want, for example, access the environment variables defined in the docker container check out: react-envs




At first create a file named env.local beside package.json and try to secure environment variables REACT_APP_YOUR ENV FILE NAME

now set the secured name to your firebase file and push it

as simple as that

Related Query

More Query from same tag