Skip to main content

createRouteManifest

declare function createRouteManifest(children: RouteChildrenProps, options: RouteManifestOptions): RouteManifest;

interface RouteManifest {
readonly routes: RouteMatchObject[];
}

Parses a <Route> tree into a RouteManifest — a ready-to-match representation of the routes. Building the manifest is the expensive step (walking the children and compiling each route's URLPattern, which is cached), so it is done once and reused; matching against it with matchRoutes is cheap.

The manifest is the data-oriented seam the router uses internally, and is published by <Routes> so that <RouterLink prefetch> and useRoutePrefetch can match arbitrary target paths without re-walking JSX.

import { createRouteManifest, matchRoutes } from '@archibald/core';

const manifest = createRouteManifest(children, { pathname });
const result = matchRoutes(manifest, '/en/cart');

Most applications never call this directly — it is used by <Routes> and by the useRouteManifest hook. It is exported for advanced use cases such as server-side matching or file-based routing.