Skip to content

docs: mention env option in the environment variables docs #77985

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

Closed
wants to merge 2 commits into from

Conversation

Netail
Copy link
Contributor

@Netail Netail commented Apr 9, 2025

Summary

Mention env option of the next config on the environment variables docs page

Came up here; #21850 (reply in thread)

cc: @delbaoliveira @leerob @samcx :)

@ijjk ijjk added the Documentation Related to Next.js' official documentation. label Apr 9, 2025
@ijjk
Copy link
Member

ijjk commented Apr 9, 2025

Allow CI Workflow Run

  • approve CI run for commit: 841cca0

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@samcx
Copy link
Member

samcx commented Apr 10, 2025

@Netail Don't think we should add this as a Good to know because default recommendation has been to use NEXT_PUBLIC_ (or not) alongside a .env file for quite some time.

@Netail
Copy link
Contributor Author

Netail commented Apr 10, 2025

@Netail Don't think we should add this as a Good to know because default recommendation has been to use NEXT_PUBLIC_ (or not) alongside a .env file for quite some time.

Maybe as a Note? It's at least worth mentioning on the page that people are aware there's ANOTHER option to set env variables besides .env files

@samcx
Copy link
Member

samcx commented Apr 10, 2025

@Netail I would just not include the mention of it overall, so folks are not pondering which one to use (adding via next.config is an ancient method and I don't think I would recommend it even).

@Netail
Copy link
Contributor Author

Netail commented Apr 10, 2025

@Netail I would just not include the mention of it overall, so folks are not pondering which one to use (adding via next.config is an ancient method and I don't think I would recommend it even).

I mean, it may not be a recommended solution, it's still a supported feature which some people might have a use case for, like the peeps from that linked discussion post (Also used by "plugins" by wrapping something around the next config to add options).

What about a (not recommended) behind it? I've seen that in the docs a few times if I remember correctly

@@ -178,6 +178,8 @@ const env = process.env
setupAnalyticsService(env.NEXT_PUBLIC_ANALYTICS_ID)
```

> **Note**: Bundled environment variables can also be set using the [`env`](/docs/app/api-reference/config/next-config-js/env) option in `next.config.js`. These do not require the `NEXT_PUBLIC_` prefix. (not recommended)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The presence of (not recommended) makes me fee like we should omit this from the docs as it being included is a form of recommending.

@Netail Netail closed this Apr 11, 2025
@Netail Netail deleted the docs/next-config-env branch April 11, 2025 21:45
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation Related to Next.js' official documentation. locked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants