You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Start: public option to turn off the hydration output for a request or route (hydrate: false)
#8989
We render server-only pages with Start and hydrate only a few small parts of each page as islands (our own small client entry, not the Start client). The router never hydrates in the browser.
createStartHandler always calls serverSsr.dehydrate(). So every response still carries the dehydrated router state and the bootstrap scripts, which the browser never uses. It costs HTML bytes and the server-side serialization work on every request.
What already exists
router-core already has the right primitive: ServerSsr.disableHydration() ("Framework-only: opt this request out of hydration output entirely (for example a hydrate: false page)"). Start has no public way to call it.
What we do now
A two-line patch of @tanstack/start-server-core 1.169.45 (dist/esm/createStartHandler.js): when the request context has hydrate: false, call disableHydration() instead of dehydrate():
-await routerInstance.serverSsr.dehydrate({ requestAssets: storedStartContext?.requestAssets, signal });+if (serverContext?.hydrate === false) routerInstance.serverSsr.disableHydration();+else await routerInstance.serverSsr.dehydrate({ requestAssets: storedStartContext?.requestAssets, signal });
This works for us in production-like tests, but a patch breaks on each update.
The idea
A public, per-request (or per-route) way to turn off the hydration output, for example:
a route option such as hydrate: false (the router-core comment already names it), or
a request-level option on the handler / request context, as in the patch above.
Either would let islands-style and fully static pages use Start without a patch. Would a PR for one of these be welcome, and which form do you prefer?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
The use case
We render server-only pages with Start and hydrate only a few small parts of each page as islands (our own small client entry, not the Start client). The router never hydrates in the browser.
createStartHandleralways callsserverSsr.dehydrate(). So every response still carries the dehydrated router state and the bootstrap scripts, which the browser never uses. It costs HTML bytes and the server-side serialization work on every request.What already exists
router-core already has the right primitive:
ServerSsr.disableHydration()("Framework-only: opt this request out of hydration output entirely (for example ahydrate: falsepage)"). Start has no public way to call it.What we do now
A two-line patch of
@tanstack/start-server-core1.169.45 (dist/esm/createStartHandler.js): when the request context hashydrate: false, calldisableHydration()instead ofdehydrate():This works for us in production-like tests, but a patch breaks on each update.
The idea
A public, per-request (or per-route) way to turn off the hydration output, for example:
hydrate: false(the router-core comment already names it), orEither would let islands-style and fully static pages use Start without a patch. Would a PR for one of these be welcome, and which form do you prefer?
All reactions