Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(env): upgrade dotenv #38481

Merged
merged 12 commits into from
Oct 17, 2023
Merged
28 changes: 27 additions & 1 deletion docs/basic-features/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@ description: Learn to add and access environment variables in your Next.js appli

# Environment Variables

> This document is for Next.js versions 9.4 and up. If you’re using an older version of Next.js, upgrade or refer to [Environment Variables in next.config.js](/docs/api-reference/next.config.js/environment-variables.md).
<details>
<summary><b>Version History</b></summary>

| Version | Changes |
| --------- | ------------------------------------------------------------------- |
| `v12.2.3` | `locale`, `locales`, `defaultLocale`, and `notFound` options added. |
balazsorban44 marked this conversation as resolved.
Show resolved Hide resolved
| `v9.4.0` | Support `.env` and `NEXT_PUBLIC_` introduced. |

This document is for Next.js versions 9.4 and up. If you’re using an older version of Next.js, upgrade or refer to [Environment Variables in next.config.js](/docs/api-reference/next.config.js/environment-variables.md).
balazsorban44 marked this conversation as resolved.
Show resolved Hide resolved

</details>

<details open>
<summary><b>Examples</b></summary>
Expand Down Expand Up @@ -75,6 +85,22 @@ export async function getStaticProps() {
> CORRECT=pre\$A
> ```

> **Note**: Next.js also supports multiline variables inside of your `.env*` files:
>
> ```bash
> # .env
balazsorban44 marked this conversation as resolved.
Show resolved Hide resolved
>
> # you can write with line breaks
> PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----
> ...
> Kh9NV...
> ...
> -----END DSA PRIVATE KEY-----"
>
> # or with `\n` inside double quotes
> PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nKh9NV...\n-----END DSA PRIVATE KEY-----\n"
> ```

> **Note**: If you are using a `/src` folder, please note that Next.js will load the .env files **only** from the parent folder and **not** from the `/src` folder.

## Exposing Environment Variables to the Browser
Expand Down
4 changes: 2 additions & 2 deletions packages/next-env/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
},
"devDependencies": {
"@vercel/ncc": "0.33.4",
"dotenv": "10.0.0",
"dotenv-expand": "8.0.1",
"dotenv": "16.0.1",
"dotenv-expand": "8.0.3",
"rimraf": "3.0.2"
}
}
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.