-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
chore: clarify runtimeConfig and process.env usage in nuxt.config #32223
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
Conversation
|
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.
Pull Request Overview
Clarify how process.env
and runtimeConfig
interact in nuxt.config.ts
, emphasizing build-time values and override syntax
- Added note that
process.env
innuxt.config.ts
returns build-time values - Explained overriding runtime config via
NUXT_MY_VAR
environment variables
WalkthroughA clarification was added to the documentation specifying that in production, the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
docs/2.guide/2.directory-structure/2.env.md (1)
56-56
: Fix spelling and improve clarity on runtimeConfig override.
There's a typo (“recieve”) and the sentence can be more precise.Apply this diff:
- * Any time you access process.env in `nuxt.config.ts` you will recieve the baked in values from build time. The only way to override runtime variables is by using the `NUXT_MY_VAR` syntax to override `runtimeConfig`. + * Any time you access `process.env` in `nuxt.config.ts`, you will receive the baked-in values from build time. To override runtime config variables, use the `NUXT_MY_VAR` syntax to set values in `runtimeConfig` at runtime.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/2.guide/2.directory-structure/2.env.md
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: lint-docs
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.
Pull Request Overview
This PR clarifies the distinction between build-time environment variables via process.env and runtime configuration in Nuxt.
- Added a note in the documentation explaining that accessing process.env in nuxt.config.ts returns build-time values and that runtime overrides require the NUXT_MY_VAR syntax.
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
docs/2.guide/2.directory-structure/2.env.md (1)
58-60
: Fix the typo and clarify warning phrasing
The link anchor contains a typo (#environment-variabes
) and the sentence is a bit awkward. Consider rephrasing for clarity and correcting the anchor:- ::warning - If you are looking to update your environment variables in production, refer to [`runtimeConfig` docs](https://nuxt.com/docs/guide/going-further/runtime-config#environment-variabes) as using `process.env` in an attempt to read environment variables at runtime will not work. + ::warning + If you need to override environment variables at runtime in production, refer to the [`runtimeConfig` docs](https://nuxt.com/docs/guide/going-further/runtime-config#environment-variables). Using `process.env` to read or update variables at runtime will not work.🧰 Tools
🪛 LanguageTool
[uncategorized] ~59-~59: Loose punctuation mark.
Context: ...ent variables at runtime will not work. :: ## Production Preview For local prod...(UNLIKELY_OPENING_PUNCTUATION)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/2.guide/2.directory-structure/2.env.md
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/2.guide/2.directory-structure/2.env.md
[uncategorized] ~59-~59: Loose punctuation mark.
Context: ...ent variables at runtime will not work. :: ## Production Preview For local prod...
(UNLIKELY_OPENING_PUNCTUATION)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: lint-docs
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 it is worth adding Alex's video on handling environment variables. There are more videos on his channel regarding nuxt's runtimeConfig.
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
docs/2.guide/2.directory-structure/2.env.md (1)
58-60
: Refine grammar and punctuation for clarity
The sentence can be improved by using a semicolon, adding a comma around “therefore,” and using “cannot” instead of “can not” for a more natural style.
Apply this diff:- `nuxt.config.ts` only runs at build time, therefore you can not change any aspect of it using environment variables at runtime. + `nuxt.config.ts` only runs at build time; therefore, you cannot change any aspect of it using environment variables at runtime.🧰 Tools
🪛 LanguageTool
[typographical] ~59-~59: The word “therefore” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence.
Context: ...antnuxt.config.ts
only runs at build time, therefore you can not change any aspect of it usi...(THUS_SENTENCE)
[style] ~59-~59: Unless you want to emphasize “not”, use “cannot” which is more common.
Context: ... only runs at build time, therefore you can not change any aspect of it using environme...(CAN_NOT_PREMIUM)
[uncategorized] ~59-~59: Loose punctuation mark.
Context: ...using environment variables at runtime. :: ## Production Preview For local prod...(UNLIKELY_OPENING_PUNCTUATION)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/2.guide/2.directory-structure/2.env.md
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/2.guide/2.directory-structure/2.env.md
[typographical] ~59-~59: The word “therefore” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence.
Context: ...ant nuxt.config.ts
only runs at build time, therefore you can not change any aspect of it usi...
(THUS_SENTENCE)
[style] ~59-~59: Unless you want to emphasize “not”, use “cannot” which is more common.
Context: ... only runs at build time, therefore you can not change any aspect of it using environme...
(CAN_NOT_PREMIUM)
[uncategorized] ~59-~59: Loose punctuation mark.
Context: ...using environment variables at runtime. :: ## Production Preview For local prod...
(UNLIKELY_OPENING_PUNCTUATION)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: lint-docs
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
docs/2.guide/2.directory-structure/2.env.md (2)
58-60
: Improve clarity and correct grammar in the important note
The sentence conflates clauses and misuses “therefore” as a conjunction. Also hyphenate and change “can not” to “cannot” for consistency.Proposed diff:
-::important -`nuxt.config.ts` only runs at build time, therefore you can not change anything in it using environment variables at runtime (including runtimeConfig). Refer to Alexamder Lichter's video -:: +::important +`nuxt.config.ts` only runs at build time; you cannot change its configuration at run-time using environment variables (including `runtimeConfig`). Refer to Alexander Lichter’s video +::🧰 Tools
🪛 LanguageTool
[typographical] ~59-~59: The word “therefore” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence.
Context: ...antnuxt.config.ts
only runs at build time, therefore you can not change anything in it using...(THUS_SENTENCE)
[style] ~59-~59: Unless you want to emphasize “not”, use “cannot” which is more common.
Context: ... only runs at build time, therefore you can not change anything in it using environment...(CAN_NOT_PREMIUM)
62-64
: Fix spelling and punctuation in the video tip
There’s a typo in “Alexamder” and the trailing punctuation could be tightened.Proposed diff:
-::tip{icon="i-lucide-video" to="https://youtu.be/_FYV5WfiWvs" target="_blank"} -Watch a video from Alexander Lichter showcasing the top mistake developers make using runtimeConfig. -:: +::tip{icon="i-lucide-video" to="https://youtu.be/_FYV5WfiWvs" target="_blank"} +Watch a video from Alexander Lichter showcasing the top mistake developers make using `runtimeConfig`. +::🧰 Tools
🪛 LanguageTool
[uncategorized] ~63-~63: Loose punctuation mark.
Context: ...ke developers make using runtimeConfig. :: ## Production Preview For local prod...(UNLIKELY_OPENING_PUNCTUATION)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/2.guide/2.directory-structure/2.env.md
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/2.guide/2.directory-structure/2.env.md
[typographical] ~59-~59: The word “therefore” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence.
Context: ...ant nuxt.config.ts
only runs at build time, therefore you can not change anything in it using...
(THUS_SENTENCE)
[style] ~59-~59: Unless you want to emphasize “not”, use “cannot” which is more common.
Context: ... only runs at build time, therefore you can not change anything in it using environment...
(CAN_NOT_PREMIUM)
[uncategorized] ~61-~61: Loose punctuation mark.
Context: ... Refer to Alexamder Lichter's video :: ::tip{icon="i-lucide-video" to="https://y...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~63-~63: Loose punctuation mark.
Context: ...ke developers make using runtimeConfig. :: ## Production Preview For local prod...
(UNLIKELY_OPENING_PUNCTUATION)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: lint-docs
I tried to improve the wording, but I am not sure if this is at all superior to just copying over the |
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
docs/2.guide/2.directory-structure/2.env.md (2)
58-61
: Fix grammar, punctuation and spelling in the important notice
The sentence currently contains a comma splice and a typo. Consider splitting into two clauses, use “cannot” instead of “can not”, and correct “Alexamder” to “Alexander”. For example:::important -`nuxt.config.ts` only runs at build time, therefore you can not change anything in it using environment variables at runtime (including runtimeConfig). Refer to Alexamder Lichter's video +`nuxt.config.ts` only runs at build time; you cannot change its configuration at runtime (including `runtimeConfig`). Refer to Alexander Lichter's video for common pitfalls. ::🧰 Tools
🪛 LanguageTool
[typographical] ~59-~59: The word “therefore” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence.
Context: ...antnuxt.config.ts
only runs at build time, therefore you can not change anything in it using...(THUS_SENTENCE)
[style] ~59-~59: Unless you want to emphasize “not”, use “cannot” which is more common.
Context: ... only runs at build time, therefore you can not change anything in it using environment...(CAN_NOT_PREMIUM)
[uncategorized] ~61-~61: Loose punctuation mark.
Context: ... Refer to Alexamder Lichter's video :: ::tip{icon="i-lucide-video" to="https://y...(UNLIKELY_OPENING_PUNCTUATION)
62-64
: Clarify the tip block wording
The tip icon and link are helpful—consider making the text more descriptive and consistent with the change above. For instance:::tip{icon="i-lucide-video" to="https://youtu.be/_FYV5WfiWvs" target="_blank"} -Watch a video from Alexander Lichter showcasing the top mistake developers make using runtimeConfig. +Watch Alexander Lichter’s video on the top mistake developers make with `runtimeConfig`. ::🧰 Tools
🪛 LanguageTool
[uncategorized] ~63-~63: Loose punctuation mark.
Context: ...ke developers make using runtimeConfig. :: ## Production Preview For local prod...(UNLIKELY_OPENING_PUNCTUATION)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/2.guide/2.directory-structure/2.env.md
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/2.guide/2.directory-structure/2.env.md
[typographical] ~59-~59: The word “therefore” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence.
Context: ...ant nuxt.config.ts
only runs at build time, therefore you can not change anything in it using...
(THUS_SENTENCE)
[style] ~59-~59: Unless you want to emphasize “not”, use “cannot” which is more common.
Context: ... only runs at build time, therefore you can not change anything in it using environment...
(CAN_NOT_PREMIUM)
[uncategorized] ~61-~61: Loose punctuation mark.
Context: ... Refer to Alexamder Lichter's video :: ::tip{icon="i-lucide-video" to="https://y...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~63-~63: Loose punctuation mark.
Context: ...ke developers make using runtimeConfig. :: ## Production Preview For local prod...
(UNLIKELY_OPENING_PUNCTUATION)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: lint-docs
Maybe just link to that page instead? I am not sure the current warning makes sense in the page about the .env file. |
Sounds like the best option to me, now that I think about it. |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
docs/2.guide/2.directory-structure/2.env.md (1)
58-61
: Fix Markdown link formatting and clarify wording.Current link syntax in the admonition block is invalid and may not render properly. Also rephrase for clarity and point directly to the Runtime Config documentation:
::important - `runtimeConfig` [won't pick up environment variables that don't start with `NUXT_` in production] (https://nuxt.com/docs/guide/going-further/runtime-config#environment-variables). + `runtimeConfig` won’t pick up environment variables that don’t start with `NUXT_` in production. For more details, see [Runtime Config Environment Variables](https://nuxt.com/docs/guide/going-further/runtime-config#environment-variables). ::🧰 Tools
🪛 LanguageTool
[uncategorized] ~59-~59: Loose punctuation mark.
Context: .../runtime-config#environment-variables). :: ## Production Preview For local prod...(UNLIKELY_OPENING_PUNCTUATION)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/2.guide/2.directory-structure/2.env.md
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/2.guide/2.directory-structure/2.env.md
[uncategorized] ~59-~59: Loose punctuation mark.
Context: .../runtime-config#environment-variables). :: ## Production Preview For local prod...
(UNLIKELY_OPENING_PUNCTUATION)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: lint-docs
@danielroe Would love some feedback 🙏 |
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.
thank you ❤️
🔗 Linked issue
Should resolve #32222
📚 Description
Clarified how runtime config works (I may be wrong in my clarification).