Skip to content

Conversation

@schiller-manuel
Copy link
Contributor

@schiller-manuel schiller-manuel commented Dec 30, 2025

after those two PRs are merged, this fixes prerendering with nitro:

nitrojs/nitro#3907
nitrojs/nitro#3908

needs https://www.npmjs.com/package/nitro-nightly/v/3.0.1-20251230-132916-74f2198d

closes #5967
close #5939

Summary by CodeRabbit

  • Chores

    • Updated development dependencies in example projects.
  • Refactor

    • Restructured plugin architecture for improved post-build hook execution ordering.
    • Enhanced build configuration with selective route prerendering and sitemap optimization.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 30, 2025

📝 Walkthrough

Walkthrough

This PR fixes prerendering failures in Nitro + SPA mode by refactoring the post-build logic into a separate plugin hook with proper ordering, updating the example's Nitro dependency to nightly, and enabling prerendering with route filtering in the example configuration.

Changes

Cohort / File(s) Summary
Example dependency
examples/solid/start-basic-nitro/package.json
Nitro devDependency updated from ^3.0.1-alpha.1 to npm:nitro-nightly@latest, replacing semver-range alpha release with nightly npm alias.
Example prerender configuration
examples/solid/start-basic-nitro/vite.config.ts
tanstackStart() now receives options object with sitemap.enabled: false and prerender enabled with route filter excluding /users, /this-route-does-not-exist, /posts/i-do-not-exist, and /deferred paths.
Plugin post-build hook
packages/start-plugin-core/src/plugin.ts
New plugin entry tanstack-start-core:post-build added with buildApp hook ordered post, extracting post-build logic into separate plugin entry to ensure correct plugin ordering and avoid prerendering issues.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

ssr

Poem

🐰 Hops and wiggles with glee
Post-build hooks now ordered right,
Prerender flows through without fight!
Routes filter smooth as morning dew,
Nitro nightly keeps us new! 🌙

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'fix: prerendering' is vague and generic, using non-descriptive terms that don't convey meaningful information about what specific prerendering issue is being fixed or how the fix works. Consider a more descriptive title such as 'fix: prerendering with Nitro by moving post-build logic to separate plugin' to better explain the actual changes made.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed All code changes directly address the requirements in linked issues #5967 and #5939: updating Nitro dependency to nightly version that includes required fixes, enabling prerendering with route filtering, disabling sitemap generation to avoid conflicts, and moving post-build logic to a separate plugin to ensure correct ordering.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing prerendering with Nitro: dependency update, vite config prerender settings, and plugin architecture change. No unrelated modifications were introduced.
✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Dec 30, 2025

View your CI Pipeline Execution ↗ for commit 8bdde46

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 15m 46s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 52s View ↗

☁️ Nx Cloud last updated this comment at 2025-12-30 17:36:30 UTC

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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)
examples/solid/start-basic-nitro/package.json (1)

20-20: Consider pinning to a specific nightly version for reproducibility.

Using @latest for the nightly package means builds won't be reproducible and could break unexpectedly if a regression is introduced in a newer nightly. The PR description mentions a specific version (nitro-nightly v3.0.1-20251230-132916-74f2198d) that's known to work.

🔎 Suggested change
-    "nitro": "npm:nitro-nightly@latest",
+    "nitro": "npm:nitro-nightly@3.0.1-20251230-132916-74f2198d",

Alternatively, if the intent is to always track the latest nightly for testing purposes, this is acceptable for an example project, but consider adding a comment explaining this choice.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c24d12a and 06a5b1b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • examples/solid/start-basic-nitro/package.json
  • examples/solid/start-basic-nitro/vite.config.ts
  • packages/start-plugin-core/src/plugin.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript strict mode with extensive type safety for all code

Files:

  • examples/solid/start-basic-nitro/vite.config.ts
  • packages/start-plugin-core/src/plugin.ts
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Implement ESLint rules for router best practices using the ESLint plugin router

Files:

  • examples/solid/start-basic-nitro/vite.config.ts
  • packages/start-plugin-core/src/plugin.ts
**/package.json

📄 CodeRabbit inference engine (AGENTS.md)

Use workspace protocol workspace:* for internal dependencies in package.json files

Files:

  • examples/solid/start-basic-nitro/package.json
🧠 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:

  • examples/solid/start-basic-nitro/vite.config.ts
  • packages/start-plugin-core/src/plugin.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:

  • examples/solid/start-basic-nitro/vite.config.ts
📚 Learning: 2025-12-25T13:04:55.492Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 6215
File: e2e/react-start/custom-basepath/package.json:13-17
Timestamp: 2025-12-25T13:04:55.492Z
Learning: In the TanStack Router repository, e2e test scripts are specifically designed to run in CI (which uses a Unix environment), so Unix-specific commands (like `rm -rf`, `&` for backgrounding, and direct environment variable assignments without `cross-env`) are acceptable in e2e test npm scripts.

Applied to files:

  • examples/solid/start-basic-nitro/vite.config.ts
🧬 Code graph analysis (1)
examples/solid/start-basic-nitro/vite.config.ts (1)
packages/router-core/src/route.ts (1)
  • path (1553-1555)
⏰ 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 (2)
examples/solid/start-basic-nitro/vite.config.ts (1)

18-28: LGTM! Configuration correctly enables prerendering with appropriate route filtering.

The filter function properly excludes dynamic routes (/users), non-existent routes, and deferred routes from prerendering. Disabling sitemap generation alongside prerendering makes sense to avoid sitemap entries for filtered routes.

packages/start-plugin-core/src/plugin.ts (1)

347-361: Clean separation of post-build logic into a dedicated plugin.

The architectural decision to extract the post-build hook into a separate plugin entry without enforce: 'pre' is sound. This ensures proper ordering with other plugins that have buildApp hooks with order: 'post', which resolves the prerendering issues with Nitro. The comment clearly documents the rationale.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 30, 2025

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@6256

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@6256

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@6256

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@6256

@tanstack/react-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@6256

@tanstack/react-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@6256

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@6256

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@6256

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@6256

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@6256

@tanstack/router-cli

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@6256

@tanstack/router-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@6256

@tanstack/router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@6256

@tanstack/router-devtools-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@6256

@tanstack/router-generator

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@6256

@tanstack/router-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@6256

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@6256

@tanstack/router-utils

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@6256

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@6256

@tanstack/solid-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@6256

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@6256

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@6256

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@6256

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@6256

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@6256

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@6256

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-fn-stubs@6256

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@6256

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@6256

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@6256

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@6256

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@6256

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@6256

@tanstack/vue-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router@6256

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-devtools@6256

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-ssr-query@6256

@tanstack/vue-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start@6256

@tanstack/vue-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-client@6256

@tanstack/vue-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-server@6256

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@6256

commit: 8bdde46

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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)
packages/start-server-core/package.json (1)

82-82: Consider adding a tracking issue or inline comment for the temporary h3 downgrade.

The version h3@2.0.1-rc.5 exists on npm with no known security vulnerabilities. However, since this is a temporary pin to work around a regression in h3 PR #1259, consider adding a TODO comment in the code or creating a tracking issue to upgrade h3 when the regression is fixed. The latest version is currently 2.0.1-rc.7.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 06a5b1b and 89c0fd7.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • packages/start-server-core/package.json
🧰 Additional context used
📓 Path-based instructions (1)
**/package.json

📄 CodeRabbit inference engine (AGENTS.md)

Use workspace protocol workspace:* for internal dependencies in package.json files

Files:

  • packages/start-server-core/package.json
🧠 Learnings (2)
📚 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:

  • packages/start-server-core/package.json
📚 Learning: 2025-12-06T15:03:07.223Z
Learnt from: CR
Repo: TanStack/router PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-06T15:03:07.223Z
Learning: Applies to **/package.json : Use workspace protocol `workspace:*` for internal dependencies in package.json files

Applied to files:

  • packages/start-server-core/package.json
⏰ 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

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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)
examples/solid/start-basic-nitro/package.json (1)

20-20: Consider pinning the nightly version for reproducibility.

The PR description mentions a specific nightly version (v3.0.1-20251230-132916-74f2198d), but @latest is used here, which will float to newer nightlies. This could cause reproducibility issues or unexpected breakage if future nightlies introduce changes.

🔎 Suggested fix to pin the nightly version
-    "nitro": "npm:nitro-nightly@latest",
+    "nitro": "npm:nitro-nightly@3.0.1-20251230-132916-74f2198d",
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 89c0fd7 and 8bdde46.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • examples/solid/start-basic-nitro/package.json
  • examples/solid/start-basic-nitro/vite.config.ts
  • packages/start-plugin-core/src/plugin.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/start-plugin-core/src/plugin.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/package.json

📄 CodeRabbit inference engine (AGENTS.md)

Use workspace protocol workspace:* for internal dependencies in package.json files

Files:

  • examples/solid/start-basic-nitro/package.json
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript strict mode with extensive type safety for all code

Files:

  • examples/solid/start-basic-nitro/vite.config.ts
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Implement ESLint rules for router best practices using the ESLint plugin router

Files:

  • examples/solid/start-basic-nitro/vite.config.ts
🧠 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:

  • examples/solid/start-basic-nitro/vite.config.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:

  • examples/solid/start-basic-nitro/vite.config.ts
📚 Learning: 2025-12-25T13:04:55.492Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 6215
File: e2e/react-start/custom-basepath/package.json:13-17
Timestamp: 2025-12-25T13:04:55.492Z
Learning: In the TanStack Router repository, e2e test scripts are specifically designed to run in CI (which uses a Unix environment), so Unix-specific commands (like `rm -rf`, `&` for backgrounding, and direct environment variable assignments without `cross-env`) are acceptable in e2e test npm scripts.

Applied to files:

  • examples/solid/start-basic-nitro/vite.config.ts
🧬 Code graph analysis (1)
examples/solid/start-basic-nitro/vite.config.ts (1)
packages/router-core/src/route.ts (1)
  • path (1553-1555)
⏰ 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 (1)
examples/solid/start-basic-nitro/vite.config.ts (1)

18-28: Prerender configuration looks good.

The configuration correctly enables prerendering while disabling sitemap generation. The filter function appropriately excludes routes that shouldn't be prerendered (likely dynamic routes, non-existent test routes, and deferred content).

@schiller-manuel schiller-manuel merged commit 062faf4 into main Dec 30, 2025
6 checks passed
@schiller-manuel schiller-manuel deleted the fix-prerender branch December 30, 2025 17:41
@mhornbacher
Copy link

Thank you! Has this been cut for a release on @tanstack/react-start?

@schiller-manuel
Copy link
Contributor Author

@mhornbacher yes in https://github.com/TanStack/router/releases/tag/v1.145.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tanstack Start prerender error nitro + spa mode breaks since v1.138.0

3 participants