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
docs: clarify environment variables behavior #36620
Conversation
@@ -46,8 +46,7 @@ export async function getStaticProps() { | |||
} | |||
``` | |||
|
|||
> **Note**: In order to keep server-only secrets safe, Next.js replaces `process.env.*` with the correct values | |||
> at build time. This means that `process.env` is not a standard JavaScript object, so you’re not able to | |||
> **Note**: In order to keep server-only secrets safe, environment variables are evaluated at build time, so only environment variables *actually* used will be included. This means that `process.env` is not a standard JavaScript object, so you’re not able to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is less clear because "evaluated" is not the same as "replaced".
Typically eval allows dynamic usage but this is pure static analysis. The syntax is very specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. Any suggestion on how we can make it more clear? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this entire page needs to be reworked but we can ship this for now
Based on #36551 (comment) making the docs more clear which also aligns with the wording of Environment Variables in Middlerware: https://nextjs.org/docs/api-reference/next/server#how-do-i-access-environment-variables
See also: #20869 (comment)
Bug
fixes #number
contributing.md
Feature
fixes #number
contributing.md
Documentation / Examples
yarn lint