What Is the Difference Between. Env. Local And. Env. Development. Local?

I used a create-react-app.

And created environment variable files. .env.local, .env.development.local

I found that .env.development ispreferred over .env.local

And env.development.local seems to have prioty over .env.development.

If so, .env.development.local is used to override .env.development what is the purpose of .env.local?

2 Answers

Here's the priority of the files for the development build and the production build:

Dev.: (npm start): .env.development.local, .env.local, .env.development, .env

Prod.: (npm run build): .env.production.local, .env.local, .env.production, .env

If you ever want to use something in your local environment without being specific to the development build or the production build, you can add some variables to your .env.local file.

Source :

3

In .env.local you can set up environment variables that are specific to your local machine and it doesn't have to be on development mode to work, so variables there will work for both development and production.

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest