-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Which project does this relate to?
Start
Describe the bug
Description:
When using TanStack Start with React 19.1 (stable), the Transitioner component fires
commitLocation → router.load() during the initial hydration render. This re-runs route
loaders, overwriting the dehydrated loaderData.
The root cause:
https://github.com/TanStack/router/blob/main/packages/router-core/src/ssr/ssr-client.ts clears match._nonReactive.dehydrated = undefined for fully SSR'd matches before the Transitioner effect fires. When load() runs, shouldSkipLoader in https://github.com/TanStack/router/blob/main/packages/router-core/src/load-matches.ts should skip dehydrated matches — but _nonReactive.dehydrated has already been cleared by hydrate(), so loaders re-run.
This doesn't happen with React canary (used in our other project) because the effect timing is different — Transitioner's commitLocation doesn't fire during hydration.
Workaround:
Re-set _nonReactive.dehydrated = true on matches before the first router.load() call.
Your Example Website or App
N/A
Steps to Reproduce the Bug or Issue
- Create a TanStack Start project with defaultSsr: true
- Add a route loader that returns a
defer()'d value - Use
useLoaderData()in the route component to read the deferred value - Build and serve with streaming SSR
- Hard refresh the page
- The deferred value from
useLoaderData()is undefined on the client — the loader re-ran
and cleared the dehydrated data
Expected behavior
Expected behavior:
Dehydrated matches should not have their loaders re-run during the initial hydration cycle. Either _nonReactive.dehydrated should be preserved until after the first load, or load() should recognise it's running during hydration and skip matches that already have loaderData.
Screenshots or Videos
No response
Platform
- Router / Start Version: [e.g. 1.121.0]
- @tanstack/react-router: 1.163.3
- @tanstack/react-start: 1.166.1
- @tanstack/router-plugin: 1.164.0
- react: 19.1.4
- react-dom: 19.1.4
- OS:
- macOS
- Browser: Chrome
- Browser Version: 146.0.7680.80
- Bundler: vite@8.0.0-beta.8
- Bundler Version: 8.0.0-beta.8
Additional context
No response