@tanstack/solid-router
Version:
Modern and scalable routing for Solid applications
41 lines (40 loc) • 2.24 kB
TypeScript
import { AnyRouter } from '@tanstack/router-core';
/**
* Match-state transfer over Solid's hydration registry — the bare pairing's
* native SSR channel (no `__TSR_SSR__` script injection, no router-owned
* stream protocol). Entries are content-addressed (`tsr:<matchId>`; match
* ids are deterministic route-id + interpolated params, so both sides
* derive the same key from the same URL), the identical mechanism
* solid-query v6 ships query payloads through (`sq:<queryHash>`).
*
* Server half: while the render takes values (`getHydrationWriter`), the
* provider writes each settled match's transferable state. Client half: the
* hydration-claiming boot — matching is synchronous, so the provider primes
* match state from the registry and commits before rendering, without
* running loaders or resolving route chunks up front. Route components
* resolve at the read point under the boundaries the server actually
* rendered (Solid `lazy` semantics), and staleness rules own any
* post-hydration refetching.
*
* Both halves no-op under TanStack Start: `router.serverSsr` marks the
* Start contract (`attachRouterServerSsrUtils` / `dehydrate` / `hydrate`),
* which owns transfer there — and a Start-hydrated router reaches the
* client boot with matches already committed, which skips it.
*/
export declare const MATCH_KEY_PREFIX = "tsr:";
export declare function serializeMatchTransfer(router: AnyRouter): void;
/**
* The hydration-claiming boot. Returns true when every synchronously
* matched route found its registry entry and the matches were committed;
* false falls back to the caller's existing behavior (no entries — a
* non-registry server, `<NoHydration>`, or a pending match the server
* skipped).
*
* Entries arrive as inline scripts that execute at document parse, so they
* are complete before any client code runs and `takeHydrationValue` reads
* them before `hydrate()` — the boot must commit BEFORE the hydration
* render (store writes inside it are owned-scope writes). Each matched
* route takes its own key: a page without entries (SPA, or Start's own
* channel) falls through at the first match.
*/
export declare function primeRouterFromRegistry(router: AnyRouter): boolean;