Skip to content

Commit

Permalink
[docs] Add env var load order (#32350)
Browse files Browse the repository at this point in the history
My team & I keep asking the question "What order are env vars _actually_ loaded in?".

This addition surfaces the order in a clear and readable way without having to read and understand the entire "Environment Variables" documentation first.

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
  • Loading branch information
jesstelford and ijjk committed Feb 6, 2022
1 parent 9081cf8 commit 8eb6ddc
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docs/basic-features/environment-variables.md
Expand Up @@ -149,3 +149,29 @@ export default async () => {
loadEnvConfig(projectDir)
}
```

## Environment Variable Load Order

Depending on the environment (as set by `NODE_ENV`), variables are loaded from the following sources in order from top-to-bottom. In all environments existing env is not overridden by following sources.

`NODE_ENV=production`

- `.env.production.local`
- `.env.local`
- `.env.production`
- `.env`

`NODE_ENV=development`

- `.env.development.local`
- `.env.local`
- `.env.development`
- `.env`

`NODE_ENV=test`

- `.env.test.local`
- `.env.test`
- `.env`

_(note: `.env.local` is not loaded when `NODE_ENV=test`)_

0 comments on commit 8eb6ddc

Please sign in to comment.