Search code examples
reactjsenvironment-variablescreate-react-app

.env file doesn't display custom environment variables


I have a .env file set up in my project ENV FILE

But when i console.log it i can only see the following object

{
  "NODE_ENV": "development",
  "PUBLIC_URL": ""
}

I tried using .env.local but the problem persists. I used create-react-app to bootstrap the react application


Solution

  • All your custom environment variables need to have the prefix REACT_APP_.

    Like this:

    REACT_APP_GOOGLE_MAP_KEY = asdfdtgsg34qrgaerg
    

    More about environment variables with create-react-app