Which project does this relate to?
Router
Describe the bug
Scenario
The app needs tenant/site routing config before router matching, because public URLs are rewritten to internal route IDs.
In the reproduction repro below:
public URL: /guides/foo
internal URL: /live/docs/$moduleId/pages/$slug
On the server, tenant routing config is available before createRouter() and rewrite.input maps the public URL to the internal route. SSR succeeds.
The same routing config is returned from dehydrate(). On the client, however, hydrate(dehydratedData) runs after the first client match. The client router is created before that data is available, so it cannot construct the same rewrite config before matchRoutes().
Complete minimal reproducer
https://github.com/alex35mil/tanstack-dehydratedData
Steps to Reproduce the Bug
Open:
http://127.0.0.1:3000/guides/foo
The client creates the router without rewrite because hydrate(dehydratedData) has not run yet. The first client match uses /guides/foo directly instead of the rewritten internal route, causing a hydration/matching mismatch. In the reported app this throws:
Invariant failed: Expected to find a match below the root match in SPA mode.
Expected behavior
There should be a supported way to access router dehydrated data before creating the client router, so the client can build createRouter({ rewrite }) with the same tenant routing config that SSR used.
Screenshots or Videos
No response
Platform
"@tanstack/react-router": "1.168.10",
"@tanstack/react-start": "1.167.16",
- OS: macOS
- Browser: Arc
- Browser Version: 1.146.0
- Bundler: vite
- Bundler Version:
Additional context
No response
Which project does this relate to?
Router
Describe the bug
Scenario
The app needs tenant/site routing config before router matching, because public URLs are rewritten to internal route IDs.
In the reproduction repro below:
On the server, tenant routing config is available before
createRouter()andrewrite.inputmaps the public URL to the internal route. SSR succeeds.The same routing config is returned from
dehydrate(). On the client, however,hydrate(dehydratedData)runs after the first client match. The client router is created before that data is available, so it cannot construct the samerewriteconfig beforematchRoutes().Complete minimal reproducer
https://github.com/alex35mil/tanstack-dehydratedData
Steps to Reproduce the Bug
Open:
The client creates the router without
rewritebecausehydrate(dehydratedData)has not run yet. The first client match uses/guides/foodirectly instead of the rewritten internal route, causing a hydration/matching mismatch. In the reported app this throws:Expected behavior
There should be a supported way to access router dehydrated data before creating the client router, so the client can build
createRouter({ rewrite })with the same tenant routing config that SSR used.Screenshots or Videos
No response
Platform
Additional context
No response