feat: prerender with vite preview server #5921
main fromrefs/pull/5921/head·merged by birkskyum(GitHub profile, opens in a new tab) This updates prerendering to use Vite's preview server instead of directly importing the server bundle. This makes prerendering runtime-agnostic. It works the same way regardless of whether your server targets Node.js, Cloudflare Workers, or other runtimes. The preview server handles the runtime differences, so the prerendering logic doesn't need to know about them.
This particularly enables Cloudflare projects to prerender with full Workers runtime support and access to all bindings. I have updated the Cloudflare packages (wrangler and @cloudflare/vite-plugin) to fix a workerd cleanup issue, and added a prerendering test for the Cloudflare e2e project to verify everything works correctly.
All existing prerendering tests for Node.js continue to pass, so no additional test coverage was needed there.
The wrangler update (039c8059af7f17a440c53b04f86904d62dbae4e6) brings a large amount of generated type definition changes, so it's recommended to review this by commit.
Summary by CodeRabbit#
New Features
- Added a /static page that exposes a Cloudflare env value and new Solid/React route scaffolding and UI (not-found and error boundaries).
- Added a preconfigured router and app shell for Solid.
Build / Runtime
- Prerender now runs via a preview server; post-build flow adjusted to run as a separate post-build step.
Dependencies
- Bumped Cloudflare Vite plugin and wrangler dev deps.
Tests
- Added E2E tests validating prerender output and /static content.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-plugin-core
View your CI Pipeline Execution ↗ for commit b954752d17c200a68f363f8a28ead281279044db
Command Status Duration Result nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded 1m 35s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 2s View ↗
☁️ Nx Cloud last updated this comment at
2025-11-20 18:43:40UTCcc: @schiller-manuel
More templates
- tanstack-router-react-example-authenticated-routes
- tanstack-router-react-example-authenticated-routes-firebase
- tanstack-router-react-example-basic
- tanstack-router-react-example-basic-default-search-params
- tanstack-router-react-example-basic-devtools-panel
- tanstack-router-react-example-basic-file-based
- tanstack-router-react-example-basic-non-nested-devtools
- tanstack-router-react-example-react-query
- tanstack-router-react-example-basic-react-query-file-based
- tanstack-router-react-example-basic-ssr-file-based
- tanstack-router-react-example-basic-ssr-streaming-file-based
- tanstack-router-react-example-basic-virtual-file-based
- tanstack-router-react-example-basic-virtual-inside-file-based
- tanstack-router-react-example-deferred-data
- tanstack-router-i18n-paraglide
- tanstack-router-react-example-kitchen-sink
- tanstack-router-react-example-kitchen-sink-file-based
- tanstack-router-react-example-kitchen-sink-react-query
- tanstack-router-react-example-kitchen-sink-react-query-file-based
- tanstack-router-react-example-large-file-based
- tanstack-router-react-example-location-masking
- tanstack-router-react-example-navigation-blocking
- tanstack-router-react-example-quickstart
- tanstack-router-react-example-quickstart-esbuild-file-based
- tanstack-router-react-example-quickstart-file-based
- tanstack-router-react-example-quickstart-rspack-file-based
- tanstack-router-react-example-quickstart-webpack-file-based
- router-monorepo-react-query
- router-mono-simple
- router-mono-simple-lazy
- tanstack-router-react-example-scroll-restoration
- tanstack-search-validator-adapters
- tanstack-start-example-bare
- tanstack-start-example-basic
- tanstack-start-example-basic-auth
- tanstack-start-example-basic-cloudflare
- tanstack-start-example-basic-react-query
- tanstack-start-example-basic-static
- tanstack-start-bun-hosting
- tanstack-start-example-clerk-basic
- tanstack-start-example-convex-trellaux
- tanstack-start-example-counter
- tanstack-start-i18n-paraglide
- tanstack-start-example-large
- tanstack-start-example-material-ui
- tanstack-start-streaming-data-from-server-functions
- tanstack-start-example-supabase-basic
- tanstack-start-tailwind-v4
- tanstack-start-example-trellaux
- tanstack-start-example-workos
- tanstack-router-react-example-view-transitions
- tanstack-router-react-example-with-framer-motion
- tanstack-router-react-example-with-trpc
- tanstack-router-react-example-with-trpc-react-query
- tanstack-router-solid-example-authenticated-routes
- tanstack-router-solid-example-authenticated-routes-firebase
- tanstack-router-solid-example-basic
- tanstack-router-solid-example-basic-default-search-params
- tanstack-router-solid-example-basic-devtools-panel
- tanstack-router-solid-example-basic-file-based
- tanstack-router-solid-example-basic-non-nested-devtools
- tanstack-router-solid-example-basic-solid-query
- tanstack-router-solid-example-basic-solid-query-file-based
- tanstack-router-solid-example-basic-ssr-file-based
- tanstack-router-solid-example-basic-ssr-streaming-file-based
- tanstack-router-solid-example-basic-virtual-file-based
- tanstack-router-solid-example-basic-virtual-inside-file-based
- tanstack-router-solid-example-deferred-data
- tanstack-router-solid-i18n-paraglide
- tanstack-router-solid-example-kitchen-sink
- tanstack-router-solid-example-kitchen-sink-file-based
- tanstack-router-solid-example-kitchen-sink-solid-query
- tanstack-router-solid-example-kitchen-sink-solid-query-file-based
- tanstack-router-solid-example-large-file-based
- tanstack-router-solid-example-location-masking
- tanstack-router-solid-example-navigation-blocking
- tanstack-router-solid-example-quickstart
- tanstack-router-solid-example-quickstart-esbuild-file-based
- tanstack-router-solid-example-quickstart-file-based
- tanstack-router-solid-example-quickstart-rspack-file-based
- tanstack-router-solid-example-quickstart-webpack-file-based
- router-solid-mono-simple
- router-solid-mono-simple-lazy
- router-solid-monorepo-solid-query
- tanstack-router-solid-example-scroll-restoration
- tanstack-solid-router-search-validator-adapters
- tanstack-solid-start-example-basic
- tanstack-solid-start-example-basic-auth
- tanstack-solid-start-example-basic-cloudflare
- tanstack-solid-start-example-basic-netlify
- tanstack-solid-start-example-basic-nitro
- tanstack-start-example-basic-solid-query
- tanstack-solid-start-example-basic-static
- tanstack-solid-start-bun-hosting
- tanstack-solid-start-example-convex-better-auth
- tanstack-solid-start-example-counter
- tanstack-solid-start-i18n-paraglide
- tanstack-solid-start-example-large
- tanstack-solid-start-streaming-data-from-server-functions
- tanstack-solid-start-example-supabase-basic
- tanstack-solid-start-tailwind-v4
- tanstack-router-solid-example-view-transitions
- tanstack-router-solid-example-with-framer-motion
- tanstack-router-solid-example-with-trpc
@tanstack/arktype-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5921@tanstack/directive-functions-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5921@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5921@tanstack/history
npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5921@tanstack/nitro-v2-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@5921@tanstack/react-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5921@tanstack/react-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5921@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5921@tanstack/react-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5921@tanstack/react-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5921@tanstack/react-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5921@tanstack/router-cli
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5921@tanstack/router-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5921@tanstack/router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5921@tanstack/router-devtools-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5921@tanstack/router-generator
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5921@tanstack/router-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5921@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5921@tanstack/router-utils
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5921@tanstack/router-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5921@tanstack/server-functions-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5921@tanstack/solid-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5921@tanstack/solid-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5921@tanstack/solid-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@5921@tanstack/solid-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5921@tanstack/solid-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5921@tanstack/solid-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5921@tanstack/start-client-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5921@tanstack/start-plugin-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5921@tanstack/start-server-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5921@tanstack/start-static-server-functions
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@5921@tanstack/start-storage-context
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5921@tanstack/valibot-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5921@tanstack/virtual-file-routes
npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5921@tanstack/zod-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5921commit:
b954752Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/start-plugin-core/src/prerender.ts (1)
62-89: Preview-server-based prerender flow looks solid; a couple of small robustness tweaks to considerThe new approach of starting a Vite preview server, resolving its URL, and then using
localFetchagainst that base is a nice way to make prerendering runtime‑agnostic and unlock Workers support. A few minor hardening points you might want to consider:Always close the preview server, even if URL resolution fails Right now,
startPreviewServerandgetResolvedUrl(previewServer)run before thetry/finally. IfgetResolvedUrlthrows (e.g.resolvedUrls.localis unexpectedly empty), the function will exit before reaching thefinallyblock andpreviewServer.close()won’t be called. It’s low‑probability, but you could avoid any leak by moving thegetResolvedUrlcall inside thetry(or wrapping server startup + URL resolution in their owntry/finallyand guardingpreviewServerbefore closing).Make redirect handling base‑URL aware instead of hard‑coding
http://localhostInlocalFetch, redirects are only treated as “local” if thelocationheader starts with'http://localhost'or'/'. Now that the preview base URL is dynamic, it may be safer to compare againstbaseUrl.origin(e.g.location.startsWith(baseUrl.origin)) rather than assuminglocalhost, which would make this logic more resilient if Vite or the runtime ever emits redirects to a different loopback host.
These are defensive improvements; the core design and flow of the new prerender implementation look correct.
Also applies to: 91-103, 265-296
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between f139f1e2bd62685472c610f256ae058f8ccddcf3 and 006ef548356cd3c415a0b27e6cbd92caad43e870.
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (8)
e2e/react-start/basic-cloudflare/package.json(2 hunks)e2e/react-start/basic-cloudflare/src/routeTree.gen.ts(3 hunks)e2e/react-start/basic-cloudflare/src/routes/static.tsx(1 hunks)e2e/react-start/basic-cloudflare/tests/app.spec.ts(2 hunks)e2e/react-start/basic-cloudflare/vite.config.ts(1 hunks)packages/start-plugin-core/src/plugin.ts(1 hunks)packages/start-plugin-core/src/post-server-build.ts(1 hunks)packages/start-plugin-core/src/prerender.ts(5 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-11-02T16:16:24.898Z
Learnt from: nlynzaad Repo: TanStack/router PR: 5732 File: packages/start-client-core/src/client/hydrateStart.ts:6-9 Timestamp: 2025-11-02T16:16:24.898Z Learning: In packages/start-client-core/src/client/hydrateStart.ts, the `import/no-duplicates` ESLint disable is necessary for imports from `#tanstack-router-entry` and `#tanstack-start-entry` because both aliases resolve to the same placeholder file (`fake-start-entry.js`) in package.json during static analysis, even though they resolve to different files at runtime.Applied to files:
e2e/react-start/basic-cloudflare/vite.config.tspackages/start-plugin-core/src/prerender.tse2e/react-start/basic-cloudflare/src/routeTree.gen.ts
📚 Learning: 2025-10-08T08:11:47.088Z
Learnt from: nlynzaad Repo: TanStack/router PR: 5402 File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21 Timestamp: 2025-10-08T08:11:47.088Z Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.Applied to files:
e2e/react-start/basic-cloudflare/tests/app.spec.tse2e/react-start/basic-cloudflare/src/routeTree.gen.ts
📚 Learning: 2025-10-01T18:31:35.420Z
Learnt from: schiller-manuel Repo: TanStack/router PR: 5330 File: e2e/react-start/custom-basepath/src/routeTree.gen.ts:58-61 Timestamp: 2025-10-01T18:31:35.420Z Learning: Do not review files named `routeTree.gen.ts` in TanStack Router repositories, as these are autogenerated files that should not be manually modified.Applied to files:
e2e/react-start/basic-cloudflare/src/routeTree.gen.ts
🧬 Code graph analysis (1)
packages/start-plugin-core/src/plugin.ts (1)
packages/start-plugin-core/src/post-server-build.ts (1)
postServerBuild(8-70)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Preview
- GitHub Check: Test
🔇 Additional comments (6)
e2e/react-start/basic-cloudflare/package.json (1)
23-36: Cloudflare tooling version bumps look aligned with the new preview-based prerender flowThe updated
@cloudflare/vite-pluginandwranglerversions make sense given the move to a preview-server-based prerender and the referenced workerd cleanup fix. Just make sure these versions remain in sync with whatever minimum versions the core plugin assumes when this lands onmain(especially around preview behavior and bindings exposure).e2e/react-start/basic-cloudflare/tests/app.spec.ts (1)
1-31: Prerender E2E test nicely covers both build artifact and runtime behaviorThe
prerender with Cloudflare Workers runtimetest looks solid: it asserts that/staticis actually prerendered todist/client/static/index.htmland then verifies, via Playwright, that the page renders with the expected heading and binding-derived content. This lines up well with the new/staticroute and prerender filter.packages/start-plugin-core/src/plugin.ts (1)
328-360: Clean separation of build vs post-build responsibilitiesMoving
postServerBuildinto a dedicatedbuildApphook withorder: 'post'keeps the corebuilder.buildAppfocused purely on building client/server environments while still guaranteeing that prerendering + sitemap run after a successful build. ThegetConfig()usage here reuses the parsedstartConfigand stays consistent with how config is resolved earlier.e2e/react-start/basic-cloudflare/vite.config.ts (1)
13-18: Prerender config correctly scopes output to/staticEnabling prerendering with a
filterthat matches onlypage.path === '/static'is a good fit for this e2e app: it keeps the prerender surface minimal while lining up with the new/staticroute and the test that assertsdist/client/static/index.htmlexists.e2e/react-start/basic-cloudflare/src/routes/static.tsx (1)
1-25:/staticroute cleanly exercises Cloudflare bindings via a server functionThe route setup looks good:
createServerFnreadsenv.MY_VARfrom the Workers environment, the loader delegates to it, andStaticPageconsumes the loader data withRoute.useLoaderData()while exposing stable test IDs. This should give strong coverage of Worker bindings in both runtime and prerender flows.packages/start-plugin-core/src/post-server-build.ts (1)
6-14: postServerBuild API adjustment matches preview-based prerender flowDropping the
serverBundleparameter and callingprerender({ startConfig, builder })keeps this helper aligned with the new preview-server-based prerender implementation while preserving the existing prerender/spa/sitemap behaviors. Call sites (in the core plugin) have been updated consistently.Also applies to: 53-59
- @@ -347,9 +347,14 @@347347 // Build the SSR bundle348348 await builder.build(server)349349 }350- const serverBundle = getBundle(VITE_ENVIRONMENT_NAMES.server)351- await postServerBuild({ builder, startConfig, serverBundle })352350 },353351 },354352 }355353 },354+ buildApp: {355+ order: 'post',356+ async handler(builder) {357+ const { startConfig } = getConfig()358+ await postServerBuild({ builder, startConfig })359+ },360+ },
I have moved the
postServerBuildstep to the buildApp hook to ensure all plugins finish their builds before we start the preview server. - e2e/react-start/basic-cloudflare/vite.config.ts line 13Resolvedby birkskyum(GitHub profile, opens in a new tab)@@ -10,4 +10,4 @@1010 projects: ['./tsconfig.json'],1111 }),1212 cloudflare({ viteEnvironment: { name: 'ssr' }, inspectorPort: false }),13- tanstackStart(),13+ tanstackStart({
That's pretty cool! Can we make the same modifications to the e2e/solid-start/basic-cloudflare suite to keep them in sync?
I can only find
e2e/react-start/basic-cloudflare. Should I make a solid version?That would be great. There's already an examples/solid/start-basic-cloudflare that can be copied over to the e2e folder, and swapped to use workspace packages
https://tanstack.com/start/latest/docs/framework/solid/examples/start-basic-cloudflare
Added in f756512
Actionable comments posted: 1
🧹 Nitpick comments (1)
e2e/solid-start/basic-cloudflare/src/components/DefaultCatchBoundary.tsx (1)
17-17: Consider adding a descriptive prefix to the error log for consistency.Other similar error boundary components in the codebase use a descriptive prefix (e.g.,
'DefaultCatchBoundary Error:') when logging errors, which aids in debugging and log filtering.Apply this diff to add a descriptive prefix:
- console.error(error) + console.error('DefaultCatchBoundary Error:', error)📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 006ef548356cd3c415a0b27e6cbd92caad43e870 and b954752d17c200a68f363f8a28ead281279044db.
⛔ Files ignored due to path filters (8)
e2e/solid-start/basic-cloudflare/public/android-chrome-192x192.pngis excluded by!**/*.pnge2e/solid-start/basic-cloudflare/public/android-chrome-512x512.pngis excluded by!**/*.pnge2e/solid-start/basic-cloudflare/public/apple-touch-icon.pngis excluded by!**/*.pnge2e/solid-start/basic-cloudflare/public/favicon-16x16.pngis excluded by!**/*.pnge2e/solid-start/basic-cloudflare/public/favicon-32x32.pngis excluded by!**/*.pnge2e/solid-start/basic-cloudflare/public/favicon.icois excluded by!**/*.icoe2e/solid-start/basic-cloudflare/public/favicon.pngis excluded by!**/*.pngpnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (20)
e2e/solid-start/basic-cloudflare/.gitignore(1 hunks)e2e/solid-start/basic-cloudflare/package.json(1 hunks)e2e/solid-start/basic-cloudflare/playwright.config.ts(1 hunks)e2e/solid-start/basic-cloudflare/postcss.config.mjs(1 hunks)e2e/solid-start/basic-cloudflare/public/site.webmanifest(1 hunks)e2e/solid-start/basic-cloudflare/src/components/DefaultCatchBoundary.tsx(1 hunks)e2e/solid-start/basic-cloudflare/src/components/NotFound.tsx(1 hunks)e2e/solid-start/basic-cloudflare/src/routeTree.gen.ts(1 hunks)e2e/solid-start/basic-cloudflare/src/router.tsx(1 hunks)e2e/solid-start/basic-cloudflare/src/routes/__root.tsx(1 hunks)e2e/solid-start/basic-cloudflare/src/routes/index.tsx(1 hunks)e2e/solid-start/basic-cloudflare/src/routes/static.tsx(1 hunks)e2e/solid-start/basic-cloudflare/src/styles/app.css(1 hunks)e2e/solid-start/basic-cloudflare/src/utils/seo.ts(1 hunks)e2e/solid-start/basic-cloudflare/tests/app.spec.ts(1 hunks)e2e/solid-start/basic-cloudflare/tests/setup/global.setup.ts(1 hunks)e2e/solid-start/basic-cloudflare/tests/setup/global.teardown.ts(1 hunks)e2e/solid-start/basic-cloudflare/tsconfig.json(1 hunks)e2e/solid-start/basic-cloudflare/vite.config.ts(1 hunks)e2e/solid-start/basic-cloudflare/wrangler.jsonc(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- e2e/solid-start/basic-cloudflare/package.json
- e2e/solid-start/basic-cloudflare/.gitignore
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2025-11-02T16:16:24.898Z
Learnt from: nlynzaad Repo: TanStack/router PR: 5732 File: packages/start-client-core/src/client/hydrateStart.ts:6-9 Timestamp: 2025-11-02T16:16:24.898Z Learning: In packages/start-client-core/src/client/hydrateStart.ts, the `import/no-duplicates` ESLint disable is necessary for imports from `#tanstack-router-entry` and `#tanstack-start-entry` because both aliases resolve to the same placeholder file (`fake-start-entry.js`) in package.json during static analysis, even though they resolve to different files at runtime.Applied to files:
e2e/solid-start/basic-cloudflare/tsconfig.jsone2e/solid-start/basic-cloudflare/src/routeTree.gen.tse2e/solid-start/basic-cloudflare/tests/setup/global.setup.ts
📚 Learning: 2025-10-08T08:11:47.088Z
Learnt from: nlynzaad Repo: TanStack/router PR: 5402 File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21 Timestamp: 2025-10-08T08:11:47.088Z Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.Applied to files:
e2e/solid-start/basic-cloudflare/src/router.tsxe2e/solid-start/basic-cloudflare/src/routeTree.gen.ts
📚 Learning: 2025-10-09T12:59:14.842Z
Learnt from: hokkyss Repo: TanStack/router PR: 5418 File: e2e/react-start/custom-identifier-prefix/public/site.webmanifest:2-3 Timestamp: 2025-10-09T12:59:14.842Z Learning: In e2e test fixtures (files under e2e directories), empty or placeholder values in configuration files like site.webmanifest are acceptable and should not be flagged unless the test specifically validates those fields.Applied to files:
e2e/solid-start/basic-cloudflare/tests/app.spec.tse2e/solid-start/basic-cloudflare/public/site.webmanifeste2e/solid-start/basic-cloudflare/playwright.config.ts
📚 Learning: 2025-09-28T21:41:45.233Z
Learnt from: nlynzaad Repo: TanStack/router PR: 5284 File: e2e/react-start/basic/server.js:50-0 Timestamp: 2025-09-28T21:41:45.233Z Learning: In Express v5, catch-all routes must use named wildcards. Use `/*splat` to match everything except root path, or `/{*splat}` (with braces) to match including root path. The old `*` syntax is not allowed and will cause "Missing parameter name" errors. This breaking change requires explicit naming of wildcard parameters.Applied to files:
e2e/solid-start/basic-cloudflare/src/routes/__root.tsx
📚 Learning: 2025-10-01T18:31:35.420Z
Learnt from: schiller-manuel Repo: TanStack/router PR: 5330 File: e2e/react-start/custom-basepath/src/routeTree.gen.ts:58-61 Timestamp: 2025-10-01T18:31:35.420Z Learning: Do not review files named `routeTree.gen.ts` in TanStack Router repositories, as these are autogenerated files that should not be manually modified.Applied to files:
e2e/solid-start/basic-cloudflare/src/routeTree.gen.ts
🧬 Code graph analysis (10)
e2e/solid-start/basic-cloudflare/src/components/NotFound.tsx (4)
examples/solid/start-basic-cloudflare/src/components/NotFound.tsx (1)
NotFound(3-25)
e2e/solid-start/server-routes/src/components/NotFound.tsx (1)
NotFound(3-25)
examples/solid/start-basic-nitro/src/components/NotFound.tsx (1)
NotFound(3-25)
e2e/solid-start/basic-solid-query/src/router.tsx (1)
NotFound(16-16)
e2e/solid-start/basic-cloudflare/src/utils/seo.ts (2)
examples/solid/start-basic/src/utils/seo.ts (1)
title(1-33)
examples/solid/start-basic-cloudflare/src/utils/seo.ts (1)
title(1-33)
e2e/solid-start/basic-cloudflare/src/components/DefaultCatchBoundary.tsx (3)
e2e/solid-start/server-routes/src/components/DefaultCatchBoundary.tsx (1)
DefaultCatchBoundary(10-53)
examples/solid/start-basic-cloudflare/src/components/DefaultCatchBoundary.tsx (1)
DefaultCatchBoundary(10-53)
examples/solid/start-basic-nitro/src/components/DefaultCatchBoundary.tsx (1)
DefaultCatchBoundary(10-53)
e2e/solid-start/basic-cloudflare/src/router.tsx (2)
e2e/solid-start/basic-cloudflare/src/components/DefaultCatchBoundary.tsx (1)
DefaultCatchBoundary(10-53)
e2e/solid-start/basic-cloudflare/src/components/NotFound.tsx (1)
NotFound(3-25)
e2e/solid-start/basic-cloudflare/tests/setup/global.teardown.ts (1)
scripts/set-ts-version.js (1)
packageJson(33-33)
e2e/solid-start/basic-cloudflare/playwright.config.ts (1)
scripts/set-ts-version.js (1)
packageJson(33-33)
e2e/solid-start/basic-cloudflare/src/routes/__root.tsx (5)
e2e/solid-start/basic-cloudflare/src/routes/index.tsx (1)
Route(5-8)
e2e/solid-start/basic-cloudflare/src/routes/static.tsx (1)
Route(5-8)
e2e/solid-start/basic-cloudflare/src/utils/seo.ts (1)
seo(1-33)
e2e/solid-start/basic-cloudflare/src/components/DefaultCatchBoundary.tsx (1)
DefaultCatchBoundary(10-53)
e2e/solid-start/basic-cloudflare/src/components/NotFound.tsx (1)
NotFound(3-25)
e2e/solid-start/basic-cloudflare/src/routes/static.tsx (2)
e2e/solid-start/basic-cloudflare/src/routes/index.tsx (1)
Route(5-8)
e2e/solid-start/basic-cloudflare/worker-configuration.d.ts (1)
env(9632-9632)
e2e/solid-start/basic-cloudflare/src/routeTree.gen.ts (1)
e2e/solid-start/basic-cloudflare/src/router.tsx (1)
getRouter(6-16)
e2e/solid-start/basic-cloudflare/src/routes/index.tsx (2)
e2e/solid-start/basic-cloudflare/src/routes/static.tsx (1)
Route(5-8)
e2e/solid-start/basic-cloudflare/worker-configuration.d.ts (1)
env(9632-9632)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test
- GitHub Check: Preview
🔇 Additional comments (20)
e2e/solid-start/basic-cloudflare/src/utils/seo.ts (1)
1-33: LGTM!The SEO utility implementation is consistent with other examples in the codebase and correctly generates meta tags for social media platforms.
e2e/solid-start/basic-cloudflare/postcss.config.mjs (1)
1-5: LGTM!Standard PostCSS configuration for Tailwind CSS integration.
e2e/solid-start/basic-cloudflare/src/styles/app.css (1)
1-30: LGTM!Standard Tailwind CSS base layer configuration with appropriate light/dark mode support.
e2e/solid-start/basic-cloudflare/src/components/DefaultCatchBoundary.tsx (1)
10-52: LGTM!The error boundary component correctly handles errors with appropriate user actions for recovery and navigation.
e2e/solid-start/basic-cloudflare/src/components/NotFound.tsx (1)
1-25: LGTM!The NotFound component is well-structured and consistent with similar implementations across the codebase. The inclusion of the test ID enables proper e2e testing.
e2e/solid-start/basic-cloudflare/tests/app.spec.ts (1)
1-31: LGTM!The test suite effectively validates Cloudflare Workers runtime behavior, including the new prerendering functionality. The prerender test correctly verifies both the build artifact and runtime behavior.
e2e/solid-start/basic-cloudflare/tests/setup/global.teardown.ts (1)
1-6: LGTM!The global teardown function properly cleans up the test server after test execution.
e2e/solid-start/basic-cloudflare/wrangler.jsonc (2)
4-4: Verify the compatibility date is appropriate.The
compatibility_dateis set to2025-09-24, which is about 2 months before the PR creation date (November 2025). Ensure this date aligns with the intended Cloudflare Workers runtime features and behaviors for this test project.
1-10: LGTM!The Wrangler configuration correctly sets up the Cloudflare Workers environment with Node.js compatibility and the required environment variable for testing.
e2e/solid-start/basic-cloudflare/public/site.webmanifest (1)
1-19: LGTM! Empty values are acceptable in e2e test fixtures.The empty
nameandshort_namefields are acceptable for an e2e test fixture, as the test does not validate these specific fields.Based on learnings
e2e/solid-start/basic-cloudflare/tests/setup/global.setup.ts (1)
1-6: LGTM!The test setup is clean and follows the standard pattern for starting the e2e dummy server.
e2e/solid-start/basic-cloudflare/tsconfig.json (1)
1-24: LGTM!The TypeScript configuration is appropriate for a SolidJS project with Cloudflare Workers support. The strict mode, modern module resolution, and path aliases are all configured correctly.
e2e/solid-start/basic-cloudflare/src/router.tsx (1)
6-16: LGTM!The router configuration is clean and follows Solid Router best practices. The settings for preload, error handling, and scroll restoration are all appropriate.
e2e/solid-start/basic-cloudflare/src/routes/__root.tsx (1)
60-86: LGTM!The RootDocument shell component is well-structured with proper hydration setup, head content, and scripts placement.
e2e/solid-start/basic-cloudflare/src/routes/index.tsx (1)
1-27: LGTM!The route implementation correctly uses Cloudflare Workers environment variables and follows Solid Start patterns. The test identifiers will enable reliable e2e testing.
e2e/solid-start/basic-cloudflare/src/routes/static.tsx (1)
1-25: LGTM!The static route implementation is clean and follows the same pattern as the index route. While there is some code duplication with the
getDataserver function, this is acceptable for e2e test fixtures where each route may have different data requirements.e2e/solid-start/basic-cloudflare/vite.config.ts (1)
7-21: LGTM!The Vite configuration is well-structured for Cloudflare Workers with SSR support. The prerender filter correctly targets only the
/staticroute, which aligns with the PR's objective to test prerendering with Cloudflare Workers runtime.e2e/solid-start/basic-cloudflare/playwright.config.ts (2)
11-38: LGTM! Well-structured Playwright configuration.The configuration correctly:
- Uses a single worker to prevent port conflicts during Cloudflare preview server testing
- Wires global setup/teardown for test lifecycle management
- Configures the preview server workflow (
build && preview) which aligns with the PR's objective of using Vite's preview server for prerendering - Sets appropriate server reuse and output handling
3-5: No issues found. Modern syntax features are properly supported.The project's Node.js version (24.4.1, specified in the root
.nvmrc) and ES module configuration ("type": "module"in package.json) fully support both import assertions and top-level await. The configuration is correct as-is.e2e/solid-start/basic-cloudflare/src/routeTree.gen.ts (1)
7-9: Skipping review of autogenerated file.This file is autogenerated by TanStack Router and should not be manually modified. Based on learnings, autogenerated
routeTree.gen.tsfiles are not reviewed.@@ -0,0 +31,21 @@31+ ],32+ links: [33+ { rel: 'stylesheet', href: appCss },34+ {35+ rel: 'apple-touch-icon',36+ sizes: '180x180',37+ href: '/apple-touch-icon.png',38+ },39+ {40+ rel: 'icon',41+ type: 'image/png',42+ sizes: '32x32',43+ href: '/favicon-32x32.png',44+ },45+ {46+ rel: 'icon',47+ type: 'image/png',48+ sizes: '16x16',49+ href: '/favicon-16x16.png',50+ },51+ { rel: 'manifest', href: '/site.webmanifest', color: '#fffff' },⚠️ Potential issue | 🟡 Minor
Fix the color value typo.
The color value
'#fffff'has 5 hexadecimal digits. Valid hex colors should be either 3 digits (#fff) or 6 digits (#ffffff).Apply this diff to fix the typo:
- { rel: 'manifest', href: '/site.webmanifest', color: '#fffff' }, + { rel: 'manifest', href: '/site.webmanifest', color: '#ffffff' },📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
Suggested change51- { rel: 'manifest', href: '/site.webmanifest', color: '#fffff' },51+ { rel: 'manifest', href: '/site.webmanifest', color: '#ffffff' },🤖 Prompt for AI Agents
In e2e/solid-start/basic-cloudflare/src/routes/__root.tsx around line 51, the meta object has an invalid color value '#fffff' (5 hex digits); replace it with a valid hex color such as '#ffffff' (or '#fff') so the color value is 6 (or 3) hex digits.birkskyum(GitHub profile, opens in a new tab) approved these changes
birkskyum(GitHub profile, opens in a new tab) closed this
Thank you @birkskyum!
@edmundhung
I'm having issues during prerendering on Cloudflare where it imports my API routes which in turn import my db.ts for Drizzle, which has my Neon Database.
It throws an error due to process.env.DATABASE_URL being undefined. This doesn't happen for local builds with pre-rendering, only on Cloudflare. It seems to be throwing away all non VITE_ environment variables, and this is causing errors during the pre-rendering phase specifically on Cloudflare, since it is importing the entire route tree including API routes which might throw when env variables are missing.
https://github.com/pgrealtime/pgrealtime/pull/8
I was able to suppress it by wrapping my Neon with a try catch, but it doesn't feel right.
It looks like the specific issue is that process.env is not being populated. I see in your example you are using
import { env } from 'cloudflare:workers'in the static page and you have environment variables working there.Here it seems that the compatibility option to load in process.env vars as well isn't happening during the prerender.
EDIT- even with using { env } binding, I'm still getting the error.
db.ts
import { env } from "cloudflare:workers" import { neon } from "@neondatabase/serverless" import { drizzle } from "drizzle-orm/neon-http" import * as schema from "./schema" const sql = neon(env.DATABASE_URL) export const db = drizzle(sql, { schema })Looks like the issue is that it is not binding my secrets, during the build, specifically:
23:51:23.795 Your Worker has access to the following bindings: 23:51:23.796 Binding Resource 23:51:23.796 env.FOO ("BAR") Environment VariableHi @daveycodez,
Thanks for giving it a try! We don't inject runtime variables and secret in the build environment for you at the moment. You will need to set them up in the build settings in the dashboard.
I will share this with the CI team to see how we can simplify this further. Just let me know if you run into any issue with prerendering. 👍🏼
@edmundhung Oh I actually also added them as both Environment Variables & Build variables and they still weren't present during the pre-render phase
That's strange. I will follow up with the team and look into the issue next week. Thanks for the update
Starting with this commit, my project's build broken with spa mode on:
✓ built in 535ms [prerender] Prerendering pages... error during build: Error: Failed to start the Vite preview server for prerendering at startPreviewServer (file:///project-dir/node_modules/.pnpm/@tanstack+start-plugin-core@1.139.6_@tanstack+react-router@1.139.6_react-dom@19.2.0_rea_4811f95400dc016e184359a72f378162/node_modules/@tanstack/start-plugin-core/dist/esm/prerender.js:195:11) at async prerender (file:///project-dir/node_modules/.pnpm/@tanstack+start-plugin-core@1.139.6_@tanstack+react-router@1.139.6_react-dom@19.2.0_rea_4811f95400dc016e184359a72f378162/node_modules/@tanstack/start-plugin-core/dist/esm/prerender.js:42:25) at async postServerBuild (file:///project-dir/node_modules/.pnpm/@tanstack+start-plugin-core@1.139.6_@tanstack+react-router@1.139.6_react-dom@19.2.0_rea_4811f95400dc016e184359a72f378162/node_modules/@tanstack/start-plugin-core/dist/esm/post-server-build.js:38:5) at async BasicMinimalPluginContext.handler (file:///project-dir/node_modules/.pnpm/@tanstack+start-plugin-core@1.139.6_@tanstack+react-router@1.139.6_react-dom@19.2.0_rea_4811f95400dc016e184359a72f378162/node_modules/@tanstack/start-plugin-core/dist/esm/plugin.js:267:11) at async Object.buildApp (file:///project-dir/node_modules/.pnpm/vite@7.2.4_@types+node@24.10.1_jiti@2.6.1_lightningcss@1.30.2_sugarss@5.0.1_postcss@8.5.6__tsx@4.20.6_yaml@2.8.1/node_modules/vite/dist/node/chunks/config.js:34542:5) at async CAC.<anonymous> (file:///project-dir/node_modules/.pnpm/vite@7.2.4_@types+node@24.10.1_jiti@2.6.1_lightningcss@1.30.2_sugarss@5.0.1_postcss@8.5.6__tsx@4.20.6_yaml@2.8.1/node_modules/vite/dist/node/cli.js:629:3) ELIFECYCLE Command failed with exit code 1.Downgrade to tanstack-start 1.137.0 works.
Sign in to join this conversation.
Walkthrough#
Adds a /static route and tests for Cloudflare e2e examples, enables prerendering for that route, and refactors post-build/prerender to run against a Vite preview server (removing reliance on a server bundle and adjusting plugin hooks and signatures).
Changes#
e2e/react-start/basic-cloudflare/src/routes/static.tsx,e2e/react-start/basic-cloudflare/src/routeTree.gen.ts/staticfile route with loader calling a server fn returningenv.MY_VAR; route tree and TypeScript route maps/types augmented to include/static.e2e/react-start/basic-cloudflare/tests/app.spec.ts,e2e/react-start/basic-cloudflare/vite.config.ts,e2e/react-start/basic-cloudflare/package.json/static; bumped@cloudflare/vite-pluginandwranglerdev deps.packages/start-plugin-core/src/plugin.ts,packages/start-plugin-core/src/post-server-build.tsserverBundleusage from build handler; moved post-build call to a dedicated plugin hook and removedserverBundleparameter frompostServerBuildsignature.packages/start-plugin-core/src/prerender.tse2e/solid-start/basic-cloudflare/*,e2e/solid-start/basic-cloudflare/src/routes/*,e2e/solid-start/basic-cloudflare/src/components/*,e2e/solid-start/basic-cloudflare/tests/*,e2e/solid-start/basic-cloudflare/vite.config.ts,e2e/solid-start/basic-cloudflare/wrangler.jsonc/and/static), router/getRouter, DefaultCatchBoundary, NotFound, styles, SEO util, Playwright config, tests, postcss, manifest, wrangler config, tsconfig, and related test setup/teardown.Sequence Diagram(s)#
Estimated code review effort#
🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs#
Suggested labels#
ssr,package: solid-start,package: react-startSuggested reviewers#
Poem#
Pre-merge checks and finishing touches#
❌ Failed checks (1 warning)
@coderabbitai generate docstringsto improve docstring coverage.✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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.
❤️ Share