[nitro 1/6] Serve the client through Nitro's Vite plugin - #4701
Draft
cprecioso wants to merge 2 commits into
Draft
[nitro 1/6] Serve the client through Nitro's Vite plugin#4701cprecioso wants to merge 2 commits into
cprecioso wants to merge 2 commits into
Conversation
Replace @wasp.sh/lib-vite-ssr with nitro/vite in the SDK Vite plugin chain: - new waspNitroBridge() plugin injects client/ssr environment inputs and the Nitro config (custom renderer, prerender routes, node-server preset) - renderer split per Nitro's architecture: plain-TS thin proxy (fetchViteEnv) + ssr-environment entry with ?assets tag collection - layout.tsx takes asset tags as head children instead of clientEntrySrc; react-refresh preamble moves into the client entry - detectServerImports/validateEnv/typescriptCheck scoped per environment - waspConfig pins the dev port against .env PORT hijacking and drops the forced client outDir (Nitro owns output at .wasp/out/web-app) - nitro pinned exactly (3.0.260610-beta); lib-vite-ssr no longer shipped The Express server is untouched and still serves on 3001; prerender (prerender: true routes) and the SPA-shell fallback now go through Nitro's renderer in both dev and build.
cprecioso
had a problem deploying
to
fly-deploy-test
August 12, 2026 15:54 — with
GitHub Actions
Failure
cprecioso
had a problem deploying
to
railway-deploy-test
August 12, 2026 15:54 — with
GitHub Actions
Failure
@wasp.sh/spec
@wasp.sh/wasp-cli
@wasp.sh/wasp-cli-darwin-arm64-unknown
@wasp.sh/wasp-cli-darwin-x64-unknown
@wasp.sh/wasp-cli-linux-arm64-glibc
@wasp.sh/wasp-cli-linux-x64-glibc
@wasp.sh/wasp-cli-linux-x64-musl
commit: |
15 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Part 1 of the Nitro migration stack (plan + spike findings in the workspace
.context/; spikes validated everything onnitro@3.0.260610-beta+ Vite 8.2.0).Nitro now serves the client (dev + build + prerender), replacing
@wasp.sh/lib-vite-ssr. The Express server is untouched and still runs standalone on 3001 — this PR changes nothing about how operations/auth/APIs are served.What changes:
wasp()composes a newwaspNitroBridge()plugin +nitro()fromnitro/viteinstead ofssr()from@wasp.sh/lib-vite-ssr. The bridge sets theclient/ssrenvironment inputs and injects the Nitro config (custom renderer,prerender.routesfromprerender: truedeclarations,node-serverpreset,serverEntry: false).fetchViteEnv("ssr", req)) asrenderer.handler(the prerender pass rebuilds this file with bare Rolldown, so it cannot contain JSX/CSS/?assets), plus the reworked ssr-environment entry that fully renders prerender-listed routes and serves a memoized SPA shell for everything else.?assetsimports;layout.tsxrenders them as head children instead of the manualclientEntrySrcscript, and the react-refresh preamble moves into the client entry (removes the Dev-mode: async client-entry races React-Refresh preamble → intermittent "can't detect preamble" / failed hydration (0.22, still on 0.23) #4258-adjacent script-injection workaround).detectServerImports/validateEnv/typescriptCheckare scoped per Vite environment (there are three now:client,ssr,nitro)..wasp/out/web-appwithpublicDir = web-app/build, soviteBuildDirPathconsumers (deploy package,wasp build start) keep working unchanged.200.htmlis kept (Fly/Railway static deploys hardcode it) as a prerender route.waspConfigpins the dev port againstPORTin user.envfiles (Nitro pre-loads.envand givesprocess.env.PORTtop precedence).Verified: 657/657 unit tests; e2e goldens regenerated and re-verified in comparison mode (937/937 twice); on a live app — dev with working Fast Refresh and clean hydration, prerendered route HTML with hydration data, SPA-shell fallback, operations roundtrip to the 3001 server in dev and preview, and all env/TS/server-import guards still firing.
Notes for review:
nitroVersionis a plainStringinDepVersions.hs— Wasp's SemVer parser doesn't support pre-release identifiers (-beta).outputconfig is injected only oncommand === "build"— setting it in dev makes Nitro serve stale build files through its production asset reader (500s). Upstream issue drafted.Type of change
Checklist
I tested my change in a Wasp app to verify that it works as intended.
🧪 Tests and apps:
examples/kitchen-sink/e2e-tests.waspc/data/Cli/templates, as needed.examples/, as needed.examples/tutorials) I updated the tutorial in the docs (and vice versa).📜 Documentation:
web/docs/.🆕 Changelog: (if change is more than just code/docs improvement)
waspc/ChangeLog.mdwith a user-friendly description of the change.web/docs/migration-guides/.versioninwaspc/waspc.cabalto reflect the changes I introduced.