Unverified Commit 7ef653c7 authored by Jim Cresswell's avatar Jim Cresswell Committed by GitHub

docs: clarify env inclusion in bundles (#41950)

Clarify that all next.config.js envs are included in the client-side bundle.

I recently came across an issue where the instructions for specifying environment variables in the next.config.js file and the instructions for specifying them in `.env` files were conflated, and a value was included in the client-side bundle that was not supposed to be there.

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
parent 2411a625
...@@ -13,6 +13,8 @@ description: Learn to add and access environment variables in your Next.js appli ...@@ -13,6 +13,8 @@ description: Learn to add and access environment variables in your Next.js appli
</ul> </ul>
</details> </details>
> <b>Note</b>: environment variables specified in this way will <b>always</b> be included in the JavaScript bundle, prefixing the environment variable name with `NEXT_PUBLIC_` only has an effect when specifying them [through the environment or .env files](/docs/basic-features/environment-variables.md).
To add environment variables to the JavaScript bundle, open `next.config.js` and add the `env` config: To add environment variables to the JavaScript bundle, open `next.config.js` and add the `env` config:
```js ```js
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment