Client router runtime
RouteRegistry matcher scoring window globals navigation View Transitions gate.
Client router runtime
Production routing executes entirely in the browser. Implementation lives under packages/manic/src/router/lib/.
Global bridges
| Global | Setter | Reader |
|---|---|---|
__MANIC_ROUTES__ | app/main.tsx assigns lazy map from ~routes.generated.ts | Router default path |
__MANIC_ERROR_PAGES__ | Same — notFound, error loaders | Router useErrorPage |
__MANIC_NAVIGATE__ | Router effect installs programmatic navigate | navigate() helper |
Matching pipeline
normalizePathtrims trailing slashes (except/).compileRouteturns each manifest key intoRegExp+ orderedparamNames+score(matcher.ts).RouteRegistrysorts descending score — static segments (+100 each) beat dynamic (+10) beat catch‑all (+1).- First regex win yields
paramsobject consumed byRouterContext.
Navigation + View Transitions
navigatepreferswindow.__MANIC_NAVIGATE__soRouterowns scroll + abort semantics.- When
router.viewTransitionsis enabled andsetViewTransitions(true), navigations wrapdocument.startViewTransitionwhen the browser supports it (Transitions).
Prefetch
preloadRoute rebuilds an ephemeral RouteRegistry from __MANIC_ROUTES__, resolves path, and kicks the lazy import() into componentCache shared with Router (API).