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

GlobalSetterReader
__MANIC_ROUTES__app/main.tsx assigns lazy map from ~routes.generated.tsRouter default path
__MANIC_ERROR_PAGES__Same — notFound, error loadersRouter useErrorPage
__MANIC_NAVIGATE__Router effect installs programmatic navigatenavigate() helper

Matching pipeline

  1. normalizePath trims trailing slashes (except /).
  2. compileRoute turns each manifest key into RegExp + ordered paramNames + score (matcher.ts).
  3. RouteRegistry sorts descending score — static segments (+100 each) beat dynamic (+10) beat catch‑all (+1).
  4. First regex win yields params object consumed by RouterContext.

  • navigate prefers window.__MANIC_NAVIGATE__ so Router owns scroll + abort semantics.
  • When router.viewTransitions is enabled and setViewTransitions(true), navigations wrap document.startViewTransition when 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).


See also

On this page