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

docs: clarify environment variables behavior #36620

Merged
merged 3 commits into from May 22, 2022

Conversation

balazsorban44
Copy link
Member

@balazsorban44 balazsorban44 commented May 2, 2022

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

  • Related issues linked using fixes #number
  • Integration tests added
  • Errors have helpful link attached, see contributing.md

Feature

  • Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
  • Related issues linked using fixes #number
  • Integration tests added
  • Documentation added
  • Telemetry added. In case of a feature if it's used or not.
  • Errors have helpful link attached, see contributing.md

Documentation / Examples

  • Make sure the linting passes by running yarn lint

@@ -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
Copy link
Member

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.

Copy link
Member Author

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? 🤔

Copy link
Member

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

styfle
styfle previously approved these changes May 3, 2022
@kodiakhq kodiakhq bot merged commit 2e1740b into canary May 22, 2022
@kodiakhq kodiakhq bot deleted the docs/clarify-env-var-behavior branch May 22, 2022 16:57
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants