Skip to content

fix: read Nitro's runtime config in the server useSafeRuntimeConfig - #48

Merged
vite-hub[bot] merged 2 commits into
mainfrom
fix/nuxt5-server-composable
Nov 9, 2026
Merged

vite-hub[bot] merged 2 commits into
mainfrom
fix/nuxt5-server-composable

Conversation

@onmax

@onmax onmax commented Nov 9, 2026

Copy link
Copy Markdown
Owner

On the Nuxt 5 nightly, every build with this module warns NUXT_B9003: Nuxt applies its Nitro v2 compatibility layer to the module because the server useSafeRuntimeConfig imports #imports. Nuxt 6 removes that layer.

The app and the server shared one composable file, and #imports is the app import. This PR gives the server import its own file, which reads useRuntimeConfig from #safe-runtime-config/nitro-runtime-config, the alias the validation plugin already uses. On Nuxt 5, Nuxt rewrites that module to its own runtime config, so both read the same object. The app composable stays the same.

I checked it against nuxt-nightly@5.0.0-2611090045-6d7dd80 with the packed module and an inline Valibot schema. main warns NUXT_B9003 and this branch doesn't. After the build, NUXT_PORT=8080 NUXT_PUBLIC_REPLAY_ENABLED=true reach useSafeRuntimeConfig(event) as a number and a boolean, and the rendered page shows true boolean. NUXT_DATABASE_URL=nope stops the server. On Nuxt 4, runtime-validator, validation (server typing through vue-tsc), cloudflare-auto-import, runtime-transform and runtime-coercion pass. I didn't add a Nuxt 5 test, because the test fixtures pin Nuxt 4.5.

The shared composable imported useRuntimeConfig from #imports. On Nuxt 5 that
import makes Nuxt apply its Nitro v2 compatibility layer to the module
(NUXT_B9003). The server import now has its own file that reads
#safe-runtime-config/nitro-runtime-config, the same alias the validation
plugin uses.
@vercel

vercel Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nuxt-safe-runtime-config Ready Ready Preview Nov 9, 2026 6:42am UTC

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-09T06:19:44.692852Z
We couldn’t complete this review. Comment @codex review to try again.
4d2734d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@pkg-pr-new

pkg-pr-new Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nuxt-safe-runtime-config@48

commit: 7262450

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Important

The automatic server import is fixed, but the documented explicit #imports server path still selects the compatibility-triggering implementation.

Reviewed changes in 4d2734d: the Nuxt app and Nitro server now register separate useSafeRuntimeConfig sources, with shared validation-state reading extracted into one helper.

  • Server auto-import split — Nitro auto-imports now read runtime config through #safe-runtime-config/nitro-runtime-config, while app imports retain Nuxt's #imports implementation.
  • Shared validated read — Both implementations call readValidatedRuntimeConfig to preserve first-read validation and transformed output.
  • Package and behavior coverage — The new server runtime builds into dist, generated Nuxt 4 Nitro imports select it, and the affected validation, coercion, transform, typing, and Cloudflare tests pass.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-5.6-sol | 𝕏

Comment thread src/module.ts Resolved
@vite-hub

vite-hub Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor
Session Status Started Duration
Pending Completed Not started —
View session Completed 2026-11-09T06:34:52.426Z 6m 58s

Latest result

Pull request merged.

Final answers

Session

Pull request merged.

View session

Pushed 7262450 fixing Pullfrog P1 explicit server import contract with #safe-runtime-config/server and updated documentation; thread resolved. pnpm dev:prepare, focused Nuxt 4 typing/coercion tests (6 passed), changed-source ESLint, and git diff --check passed. Dependency refresh succeeded, though checkDependencies still rejects the existing minimumReleaseAgeExcludePrune setting. Awaiting hosted CI.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No new issues found. No P0 or P1 finding remains.

Reviewed changes since the prior Pullfrog review addressed the explicit server import contract without reintroducing Nuxt's Nitro v2 compatibility path.

  • Added a server entry point — Registered #safe-runtime-config/server as an alias to the Nitro-specific useSafeRuntimeConfig implementation.
  • Narrowed the import contract — Documented #imports for app code and the new server alias for explicit imports in server code.
  • Covered explicit imports — Extended the typing and runtime-coercion fixtures to exercise the server alias with typed and event-scoped config.

Pullfrog  | View workflow run | Using gpt-5.6-sol | 𝕏

@vite-hub
vite-hub Bot merged commit 9614028 into main Nov 9, 2026
6 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 9, 2026

This branch was successfully deployed

1 active deployment
Preview — 72624507 Deployed Nov 9, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant