perf: reuse prepared SSR request locations #8441
main fromrefs/pull/8441/head·merged by schiller-manuel(GitHub profile, opens in a new tab) 🎯 Changes#
Reuse the request location already prepared by the router during SSR. Server-route handling matches that parsed pathname instead of running the input rewrite again, while preserving encoded pathnames for handlers and middleware. SSR loading also skips the redundant location update; ordinary router loads retain their existing behavior.
Rebased on main after #7588.
Validation: router-core and start-server-core unit, type, and lint checks passed, along with the server-routes e2e (10 tests) and response-reconciliation e2e in all four modes. Regression coverage includes rewrites, encoded parameters, basepaths, mutable history, and route middleware.
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested code changes locally with the relevant test commands, or tests do not apply to this pull request.
- I fully understand the code in this pull request, including any code generated with AI assistance.
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-core
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-server-core
View your CI Pipeline Execution ↗ for commit 28ba702d49ac7ec6f6f10df9c4bc338fd7a45cfb
Command Status Duration Result nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded 10m 23s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 1m 59s View ↗
☁️ Nx Cloud last updated this comment at
2026-10-12 23:18:33UTC🚀 Changeset Version Preview#
14 package(s) bumped directly, 9 bumped as dependents.
🟨 Minor bumps#
Package Version Reason @tanstack/react-start1.168.61 → 1.169.0 Changeset @tanstack/solid-start1.168.58 → 1.169.0 Changeset @tanstack/vue-start1.168.57 → 1.169.0 Changeset 🟩 Patch bumps#
Package Version Reason @tanstack/react-start-rsc0.1.60 → 0.1.61 Changeset @tanstack/react-start-server1.167.47 → 1.167.48 Changeset @tanstack/router-core1.171.35 → 1.171.36 Changeset @tanstack/router-generator1.167.41 → 1.167.42 Changeset @tanstack/router-plugin1.168.43 → 1.168.44 Changeset @tanstack/solid-start-server1.167.45 → 1.167.46 Changeset @tanstack/start-client-core1.170.35 → 1.170.36 Changeset @tanstack/start-plugin-core1.171.50 → 1.171.51 Changeset @tanstack/start-server-core1.169.40 → 1.169.41 Changeset @tanstack/start-storage-context1.167.37 → 1.167.38 Changeset @tanstack/vue-start-server1.167.45 → 1.167.46 Changeset @tanstack/react-router1.170.42 → 1.170.43 Dependent @tanstack/react-start-client1.168.40 → 1.168.41 Dependent @tanstack/router-cli1.167.41 → 1.167.42 Dependent @tanstack/router-vite-plugin1.167.43 → 1.167.44 Dependent @tanstack/solid-router1.170.39 → 1.170.40 Dependent @tanstack/solid-start-client1.168.38 → 1.168.39 Dependent @tanstack/start-static-server-functions1.167.40 → 1.167.41 Dependent @tanstack/vue-router1.170.38 → 1.170.39 Dependent @tanstack/vue-start-client1.167.41 → 1.167.42 Dependent Bundle Size Benchmarks#
This pull request does not affect bundle size in any measured scenario.
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-router-react-example-basic-authjs
- tanstack-start-example-basic-cloudflare
- tanstack-start-example-basic-react-query
- tanstack-start-example-basic-rsbuild
- 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-example-next-migration
- tanstack-start-example-rscs
- 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
- @tanstack/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-authjs
- 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-router-vue-example-basic-jsx
- tanstack-router-vue-example-basic-file-based-jsx
- tanstack-router-vue-example-basic-file-based-sfc
@tanstack/arktype-adapter
npm i https://pkg.pr.new/@tanstack/arktype-adapter@8441@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@8441@tanstack/eslint-plugin-start
npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8441@tanstack/history
npm i https://pkg.pr.new/@tanstack/history@8441@tanstack/react-router
npm i https://pkg.pr.new/@tanstack/react-router@8441@tanstack/react-router-devtools
npm i https://pkg.pr.new/@tanstack/react-router-devtools@8441@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@8441@tanstack/react-start
npm i https://pkg.pr.new/@tanstack/react-start@8441@tanstack/react-start-client
npm i https://pkg.pr.new/@tanstack/react-start-client@8441@tanstack/react-start-rsc
npm i https://pkg.pr.new/@tanstack/react-start-rsc@8441@tanstack/react-start-server
npm i https://pkg.pr.new/@tanstack/react-start-server@8441@tanstack/router-cli
npm i https://pkg.pr.new/@tanstack/router-cli@8441@tanstack/router-core
npm i https://pkg.pr.new/@tanstack/router-core@8441@tanstack/router-devtools
npm i https://pkg.pr.new/@tanstack/router-devtools@8441@tanstack/router-devtools-core
npm i https://pkg.pr.new/@tanstack/router-devtools-core@8441@tanstack/router-generator
npm i https://pkg.pr.new/@tanstack/router-generator@8441@tanstack/router-plugin
npm i https://pkg.pr.new/@tanstack/router-plugin@8441@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@8441@tanstack/router-utils
npm i https://pkg.pr.new/@tanstack/router-utils@8441@tanstack/router-vite-plugin
npm i https://pkg.pr.new/@tanstack/router-vite-plugin@8441@tanstack/solid-router
npm i https://pkg.pr.new/@tanstack/solid-router@8441@tanstack/solid-router-devtools
npm i https://pkg.pr.new/@tanstack/solid-router-devtools@8441@tanstack/solid-router-ssr-query
npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@8441@tanstack/solid-start
npm i https://pkg.pr.new/@tanstack/solid-start@8441@tanstack/solid-start-client
npm i https://pkg.pr.new/@tanstack/solid-start-client@8441@tanstack/solid-start-server
npm i https://pkg.pr.new/@tanstack/solid-start-server@8441@tanstack/start-client-core
npm i https://pkg.pr.new/@tanstack/start-client-core@8441@tanstack/start-fn-stubs
npm i https://pkg.pr.new/@tanstack/start-fn-stubs@8441@tanstack/start-plugin-core
npm i https://pkg.pr.new/@tanstack/start-plugin-core@8441@tanstack/start-server-core
npm i https://pkg.pr.new/@tanstack/start-server-core@8441@tanstack/start-static-server-functions
npm i https://pkg.pr.new/@tanstack/start-static-server-functions@8441@tanstack/start-storage-context
npm i https://pkg.pr.new/@tanstack/start-storage-context@8441@tanstack/valibot-adapter
npm i https://pkg.pr.new/@tanstack/valibot-adapter@8441@tanstack/virtual-file-routes
npm i https://pkg.pr.new/@tanstack/virtual-file-routes@8441@tanstack/vue-router
npm i https://pkg.pr.new/@tanstack/vue-router@8441@tanstack/vue-router-devtools
npm i https://pkg.pr.new/@tanstack/vue-router-devtools@8441@tanstack/vue-router-ssr-query
npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@8441@tanstack/vue-start
npm i https://pkg.pr.new/@tanstack/vue-start@8441@tanstack/vue-start-client
npm i https://pkg.pr.new/@tanstack/vue-start-client@8441@tanstack/vue-start-server
npm i https://pkg.pr.new/@tanstack/vue-start-server@8441@tanstack/zod-adapter
npm i https://pkg.pr.new/@tanstack/zod-adapter@8441commit:
28ba702Merging this PR will degrade performance by 5.15%#
⚡ 1improved benchmark❌ 2regressed benchmarks✅ 191untouched benchmarks⏩ 3skipped benchmarks1Warning
Please fix the performance issues or acknowledge them on CodSpeed.
Performance Changes#
Mode Benchmark BASEHEADEfficiency ❌ Memory mem server error-paths redirect (solid)10.3 KB 12.1 KB -14.48% ❌ Memory mem server error-paths unmatched (vue)81.6 KB 84.4 KB -3.34% ⚡ Simulation ssr rewrite localized (solid)204.6 ms 198.3 ms +3.22% Tip
Investigate this regression by commenting
@codspeedbot fix this regressionon this PR, or directly use the CodSpeed MCP with your agent.
Comparingcodex/reuse-ssr-request-location(28ba702) withmain(f243c61)Footnotes#
-
3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
-
Sheraff(GitHub profile, opens in a new tab) approved these changes
- packages/start-server-core/src/createStartHandler.ts line 1149Resolvedby schiller-manuel(GitHub profile, opens in a new tab)@@ -893,5 +892,6 @@893892 executedRequestMiddlewares: Set<AnyRequestMiddleware>894893 }): Promise<SsrResponse> {895894 const router = await getRouter()896- const rewrittenUrl = executeRewriteInput(router.rewrite, url)897- const pathname = rewrittenUrl.pathname895+ const location = router.latestLocation896+ // Preserve the encoded pathname exposed to server handlers and middleware.897+ const pathname = location.href.split(/[?#]/, 1)[0]!
regex is not the best idea
fixed on top
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-plugin-core
schiller-manuel(GitHub profile, opens in a new tab) changed the title
schiller-manuel(GitHub profile, opens in a new tab) changed the title
🦋 Changeset detected#
Latest commit: 28ba702d49ac7ec6f6f10df9c4bc338fd7a45cfb
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 23 packages
Name Type @tanstack/router-core Patch @tanstack/start-server-core Patch @tanstack/react-router Patch @tanstack/react-start-client Patch @tanstack/react-start-rsc Patch @tanstack/react-start-server Patch @tanstack/router-generator Patch @tanstack/router-plugin Patch @tanstack/solid-router Patch @tanstack/solid-start-client Patch @tanstack/solid-start-server Patch @tanstack/start-client-core Patch @tanstack/start-plugin-core Patch @tanstack/start-storage-context Patch @tanstack/vue-router Patch @tanstack/vue-start-client Patch @tanstack/vue-start-server Patch @tanstack/react-start Patch @tanstack/solid-start Patch @tanstack/vue-start Patch @tanstack/router-cli Patch @tanstack/router-vite-plugin Patch @tanstack/start-static-server-functions Patch Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Sign in to join this conversation.
Important
Review skipped#
The saved review history does not include the base for the last reviewed commit. This saved history cannot establish the base for an incremental review. Comment
@coderabbitai full reviewto establish a new review baseline. No full review was started, and the last reviewed checkpoint was preserved.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
5879088e-e6c0-4f8d-9779-39a7c7f7c235📥 Commits
Reviewing files that changed from the base of the PR and between b7600ee48d874488ef79be87a9301d3671224501 and 3df2769b5d94f19149e020e6e8a154c4e167cd7d.
📒 Files selected for processing (19)
.changeset/polite-gifts-camp.mdpackages/start-plugin-core/src/global.d.tspackages/start-plugin-core/src/rsbuild/start-router-plugin.tspackages/start-plugin-core/src/rsbuild/virtual-modules.tspackages/start-plugin-core/src/start-manifest-plugin/manifestBuilder.tspackages/start-plugin-core/src/start-router-plugin/generator-plugins/routes-manifest-plugin.tspackages/start-plugin-core/src/start-router-plugin/pruneServerOnlySubtrees.tspackages/start-plugin-core/src/vite/dev-server-plugin/plugin.tspackages/start-plugin-core/src/vite/start-manifest-plugin/plugin.tspackages/start-plugin-core/src/vite/start-router-plugin/plugin.tspackages/start-plugin-core/tests/routes-manifest-plugin.test.tspackages/start-plugin-core/tests/rsbuild/virtual-modules.test.tspackages/start-plugin-core/tests/start-manifest-plugin.test.tspackages/start-plugin-core/tests/start-manifest-plugin/manifestBuilder.test.tspackages/start-server-core/src/createStartHandler.tspackages/start-server-core/src/tanstack-start.d.tspackages/start-server-core/tests/createStartHandler.test.tspackages/start-server-core/tests/fixtures/start-manifest.tspackages/start-server-core/tsconfig.jsonIncluded review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
SSR request handling now reuses the parsed request location. Server-route matching uses the prepared pathname, while handlers and middleware retain encoded pathnames. Build manifests now expose whether server routes exist.
Changes#
SSR and server-route handling
packages/router-core/src/router.ts,packages/router-core/src/load-server.ts,packages/router-core/src/ssr/createRequestHandler.ts,packages/router-core/tests/server-history.test.tslatestLocation. Tests cover rewrites, refreshes, search parsing, and loader data.packages/start-plugin-core/src/start-router-plugin/*,packages/start-plugin-core/src/start-manifest-plugin/*,packages/start-plugin-core/src/vite/*,packages/start-plugin-core/src/rsbuild/*hasServerRoutes. Build and development paths provide fallback values.packages/start-server-core/src/createStartHandler.ts,packages/start-server-core/src/tanstack-start.d.tspackages/start-plugin-core/tests/*,packages/start-server-core/tests/*,.changeset/polite-gifts-camp.mdPriority: ⬇️ Low
Estimated code review effort: 4 (Complex) | ~45 minutes
Change: Refactor
Sequence Diagram(s)#
Suggested reviewers:
sheraffMerge Risk: ⚪ Minimal · up to
3df27The SSR request-location and server-route manifest changes retain their documented routing, rewrite, and fallback behavior. No concrete merge-blocking risk remains.
Pre-merge checks ·
4 · 
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 15.63% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 32 functions across 21 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
🧪 Generate unit tests (beta)