next.js
next.js copied to clipboard
docs: clarify env inclusion in bundles
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
cc @mcky
FWIW, the recommendation is to use https://nextjs.org/docs/basic-features/environment-variables which has safety checks to exclude environment variables that are only meant for the server.
FWIW, the recommendation is to use https://nextjs.org/docs/basic-features/environment-variables which has safety checks to exclude environment variables that are only meant for the server.
@balazsorban44 absolutely, I just wanted to clarify that the safeguarding mechanism doesn't work for the old approach.