Skip to content

fix: keep server-rendered pending UI of no-SSR routes through hydration (take 2) - #8649

Draft
Sheraff wants to merge 2 commits into
mainfrom
fix/no-ssr-hydration-v2
Draft

Sheraff wants to merge 2 commits into
mainfrom
fix/no-ssr-hydration-v2

Conversation

@Sheraff

@Sheraff Sheraff commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

🎯 Changes

Fixes #8640. Replaces #8643, which was reverted in #8646 because of a React hydration mismatch on no-SSR routes without a pendingComponent.

All adapters (same as #8643): a no-SSR match renders its server pending UI through the normal pending path, so hydration renders it at the same position. The ClientOnly wrapper (and Solid's shouldSkipSuspenseFallback) is removed.

React only. React can hydrate a route's Suspense boundary after the shell commits, and the client load can commit in between. @tanstack/react-store's useSelector passes the same function as client and server snapshot, so that late hydration render read the live store (success) against the server's pending HTML. Before, with a pendingComponent, pendingMinMs (default 500 ms) happened to hold the match pending long enough. Without one, it committed at once.

  • hydrate() keeps the matches it presented on router._hydrated. Match reads its store with React.useSyncExternalStore, using that match as the server snapshot.
  • MatchInner doesn't suspend over its own pending UI rendered in place. Doing so would hide it and mount a second copy. It still suspends to keep committed content or errors alive. A ref tracks the in-place state; it starts true for the hydrated pending match.
const match = React.useSyncExternalStore(
  subscribe,
  () => matchStore.get(),
  () =>
    router._hydrated?.find((hydrated) => hydrated.routeId === routeId) ??
    matchStore.get(),
)!

Tests (first commit, in each adapter):

  • issue-8640-data-only-pending-hydration: real SSR + hydration for success, error, notFound, unmatched URL, ssr: false invalid search, and a failing child. Each case runs with a pendingComponent (single server skeleton, held for pendingMinMs) and without one (no hydration mismatch).
  • no-ssr-client-navigation: SSR + hydration, then a param navigation. The client route tree has no ssr, as Start's client build strips it. The component must keep its state. React also shows pending UI during the navigation.

Removing any React piece fails tests: the server snapshot (7), the hydration seed (1), the layout-effect update (2).

Open question: router._hydrated keeps the first page's presented matches (including loader data) for the router's lifetime, because a boundary can hydrate arbitrarily late.

Found while testing, not changed here: in Solid and Vue, a param navigation that shows pending UI remounts the route component, also for ssr: true routes.

Bundle-size pass not done yet.

AI-assisted (Claude).

✅ 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).

🤖 Generated with Claude Code

Sheraff and others added 2 commits October 9, 2026 22:16
Restores the #8640 hydration matrix from #8643 for React, Solid and Vue, adds
every case without a pending component, and adds SSR + hydration + param
navigation tests (the client route tree has no `ssr` option, as Start's
client build strips it). Without a pending component nothing holds the match
pending, so React can hydrate the route's boundary after the client load
commits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fixes #8640 without the React hydration mismatch that reverted #8643.

All adapters: a no-SSR match renders its server pending UI through the same
pending path the hydrating client uses, at the same position, instead of a
`ClientOnly` fallback that is swapped out after hydration.

React only, since it can hydrate a route's boundary after the client load
commits:
- `hydrate()` keeps the matches it presented on `router._hydrated`. `Match`
  reads them as its `useSyncExternalStore` server snapshot, so a late
  hydration render matches the server HTML, then catches up.
- `MatchInner` suspends only to keep other committed output alive. Pending UI
  already in place, including the one hydration adopts, stays in place
  instead of being hidden behind a second copy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@changeset-bot

changeset-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 95a1794

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/react-router Patch
@tanstack/solid-router Patch
@tanstack/vue-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-start-client Patch
@tanstack/solid-start-server Patch
@tanstack/start-client-core Patch
@tanstack/start-plugin-core Patch
@tanstack/start-server-core Patch
@tanstack/start-storage-context 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

@coderabbitai

coderabbitai Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

5 package(s) bumped directly, 19 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/history 1.162.4 → 1.162.5 Changeset
@tanstack/react-router 1.170.41 → 1.170.42 Changeset
@tanstack/router-core 1.171.34 → 1.171.35 Changeset
@tanstack/solid-router 1.170.38 → 1.170.39 Changeset
@tanstack/vue-router 1.170.37 → 1.170.38 Changeset
@tanstack/react-start 1.168.60 → 1.168.61 Dependent
@tanstack/react-start-client 1.168.39 → 1.168.40 Dependent
@tanstack/react-start-rsc 0.1.59 → 0.1.60 Dependent
@tanstack/react-start-server 1.167.46 → 1.167.47 Dependent
@tanstack/router-cli 1.167.40 → 1.167.41 Dependent
@tanstack/router-generator 1.167.40 → 1.167.41 Dependent
@tanstack/router-plugin 1.168.42 → 1.168.43 Dependent
@tanstack/router-vite-plugin 1.167.42 → 1.167.43 Dependent
@tanstack/solid-start 1.168.57 → 1.168.58 Dependent
@tanstack/solid-start-client 1.168.37 → 1.168.38 Dependent
@tanstack/solid-start-server 1.167.44 → 1.167.45 Dependent
@tanstack/start-client-core 1.170.34 → 1.170.35 Dependent
@tanstack/start-plugin-core 1.171.49 → 1.171.50 Dependent
@tanstack/start-server-core 1.169.39 → 1.169.40 Dependent
@tanstack/start-static-server-functions 1.167.39 → 1.167.40 Dependent
@tanstack/start-storage-context 1.167.36 → 1.167.37 Dependent
@tanstack/vue-start 1.168.56 → 1.168.57 Dependent
@tanstack/vue-start-client 1.167.40 → 1.167.41 Dependent
@tanstack/vue-start-server 1.167.44 → 1.167.45 Dependent

@nx-cloud

nx-cloud Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 95a1794

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 12m 25s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 2m 8s View ↗

☁️ Nx Cloud last updated this comment at 2026-10-09 20:34:22 UTC

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: 83e1806cf7e0
  • Measured at: 2026-10-09T20:20:50.791Z
  • Baseline source: history:f6d21de12b69
  • Dashboard: bundle-size history

The following scenarios have bundle-size changes compared with the baseline:

Scenario Current (gzip) Initial (gzip) Raw Brotli Trend
react-router.minimal 84.0 KiB
+4 B
83.8 KiB
+5 B
261.4 KiB
+20 B
73.3 KiB
+90 B
▅▅███████▁██
react-router.full 87.6 KiB
+61 B
87.4 KiB
+62 B
273.4 KiB
+223 B
76.5 KiB
+108 B
▁▁▄▄▄▄▄▄▄▃▄█
solid-router.minimal 33.4 KiB
-80 B
33.3 KiB
-83 B
95.3 KiB
-447 B
30.2 KiB
-138 B
██▆▆▆▆▆▆▆▁▆▁
solid-router.full 38.3 KiB
-62 B
38.2 KiB
-61 B
110.2 KiB
-302 B
34.6 KiB
-97 B
██▇▇▇▇▇▇▇▁▇▁
vue-router.minimal 49.4 KiB
-48 B
49.3 KiB
-50 B
136.4 KiB
-166 B
44.7 KiB
-105 B
▂▂███████▁█▁
vue-router.full 55.0 KiB
-45 B
54.9 KiB
-46 B
154.7 KiB
-166 B
49.7 KiB
-144 B
▁▁███████▁█▁
react-start.minimal 96.8 KiB
+65 B
96.6 KiB
+64 B
302.4 KiB
+150 B
84.0 KiB
+116 B
██▇▇▇▇▇▇▃▁▃█
react-start.query-integration 104.2 KiB
+65 B
104.1 KiB
+61 B
329.0 KiB
+158 B
90.6 KiB
+160 B
▆▆▇▇▇▇▇▇▃▁▃█
react-start.deferred-hydration 97.5 KiB
+64 B
96.7 KiB
+62 B
303.7 KiB
+150 B
84.7 KiB
+44 B
▇▇▇▇▇▇▇▇▃▁▃█
react-start.full 100.0 KiB
+75 B
99.8 KiB
+75 B
312.2 KiB
+238 B
86.7 KiB
-9 B
▄▄▆▆▆▆▆▆▂▁▂█
react-start.rsbuild.minimal 100.4 KiB
+58 B
100.2 KiB
+58 B
313.3 KiB
+128 B
86.7 KiB
+67 B
▃▃██████▃▁▃█
react-start.rsbuild.minimal-iife 100.8 KiB
+58 B
100.6 KiB
+58 B
314.3 KiB
+128 B
87.0 KiB
+47 B
▃▃██████▃▁▃█
react-start.rsbuild.full 103.7 KiB
+85 B
103.5 KiB
+85 B
323.6 KiB
+238 B
89.4 KiB
+28 B
▂▂▆▆▆▆▆▆▂▁▂█
solid-start.minimal 46.2 KiB
-67 B
46.1 KiB
-66 B
135.0 KiB
-431 B
41.2 KiB
-35 B
██▅▅▅▅▅▅▄▁▄▁
solid-start.deferred-hydration 49.2 KiB
-84 B
46.1 KiB
-83 B
142.4 KiB
-437 B
44.0 KiB
-39 B
██▅▅▅▅▅▅▄▁▄▁
solid-start.full 51.3 KiB
-43 B
51.2 KiB
-45 B
150.6 KiB
-285 B
45.6 KiB
+10 B
██▆▆▆▆▆▆▄▁▄▁
vue-start.minimal 65.4 KiB
-46 B
65.3 KiB
-47 B
185.8 KiB
-152 B
58.4 KiB
-84 B
▇▇██████▅▁▅▁
vue-start.full 69.2 KiB
-55 B
69.1 KiB
-52 B
198.1 KiB
-152 B
61.7 KiB
-94 B
██▇▇▇▇▇▇▄▁▄▁

Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better.

@pkg-pr-new

pkg-pr-new Bot commented Oct 9, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@8649

@tanstack/eslint-plugin-router

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

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8649

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@8649

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@8649

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@8649

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@8649

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@8649

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@8649

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@8649

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@8649

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@8649

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@8649

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@8649

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@8649

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@8649

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@8649

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@8649

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@8649

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@8649

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@8649

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@8649

commit: 95a1794

@codspeed

codspeed Bot commented Oct 9, 2026

Copy link
Copy Markdown

Merging this PR will regress 4 benchmarks

ℹ️ 3 benchmarks have no flame graph

The flamegraph could not be generated because too much time was spent in runtime internals, making the visualization not useful for performance analysis.

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 17 improved benchmarks
❌ 4 regressed benchmarks
✅ 173 untouched benchmarks
⏩ 3 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Memory mem client unique-location-churn (react) 68.1 KB 77.2 KB -11.77%
❌ Memory mem server aborted-requests (solid) 142.9 KB 151.9 KB -5.89%
❌ Memory mem server request-churn (solid) 129.5 KB 134.4 KB -3.66%
❌ Memory mem client unique-location-churn (solid) 61.5 KB 63.7 KB -3.33%
⚡ Simulation client-nested-params navigation loop (solid) 761.7 ms 691.1 ms +10.21%
⚡ Memory mem client navigation-churn (solid) 88.6 KB 80.4 KB +10.2%
⚡ Memory mem client unique-location-churn (vue) 96.2 KB 88.9 KB +8.3%
⚡ Simulation client-history navigation loop (solid) 93.9 ms 87.9 ms +6.81%
⚡ Simulation client-route-tree-scale navigation loop (solid) 220.1 ms 206.1 ms +6.79%
⚡ Simulation client-rewrites navigation loop (solid) 128.2 ms 120.4 ms +6.55%
⚡ Memory mem client preload-churn (solid) 76.2 KB 71.9 KB +5.99%
⚡ Memory mem client mount-unmount (solid) 80.9 KB 76.4 KB +5.9%
⚡ Simulation client-async-pipeline navigation loop (solid) 113 ms 107.2 ms +5.43%
⚡ Simulation client-control-flow navigation loop (solid) 99 ms 94.1 ms +5.23%
⚡ Simulation client-loaders navigation loop (solid) 144.1 ms 137.3 ms +4.97%
⚡ Memory mem server error-paths not-found (vue) 127.8 KB 122.4 KB +4.42%
⚡ Simulation client-preload interaction loop (solid) 151 ms 144.6 ms +4.41%
⚡ Simulation client-head navigation loop (solid) 401.7 ms 387.9 ms +3.55%
⚡ ℹ️ Simulation client-search-params navigation loop (solid) 223.6 ms 216.5 ms +3.31%
⚡ Simulation client-mount loop (solid) 90.5 ms 87.6 ms +3.3%
... ... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fix/no-ssr-hydration-v2 (95a1794) with main (f6d21de)

Open in CodSpeed

Footnotes

  1. 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. ↩

This branch has not been deployed

No deployments
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.

data-only route mounts a second pendingComponent after hydration when pendingMinMs is set

1 participant