next.js icon indicating copy to clipboard operation
next.js copied to clipboard

docs: clarify env inclusion in bundles

Open jimCresswell opened this issue 2 years ago • 1 comments

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

jimCresswell avatar Oct 27 '22 08:10 jimCresswell

cc @mcky

jimCresswell avatar Oct 27 '22 09:10 jimCresswell

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 avatar Oct 28 '22 22:10 balazsorban44

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.

jimCresswell avatar Oct 29 '22 10:10 jimCresswell