Cookbook Router
@cookbook/router-react

@cookbook/router-react

The complete React adapter: providers, typed links, route rendering, outlets, slots, lazy views, public contexts, and every hook.

@cookbook/router-react is the React 18+ adapter for the renderer-neutral core. It does not own matching, URL parsing, middleware, route validation, or navigation. It subscribes to a core Router, converts resolved matches to React output, and exposes typed components and hooks.

Import surface

import {
  Link,
  NavLink,
  Outlet,
  RouterProvider,
  Slot,
  lazyRouteView,
  useNavigate,
  useParams,
} from '@cookbook/router-react';

The package publishes one root entrypoint. Internal source paths are not public API.

Reference map

AreaWhat is covered
Providers and render helpersRouterProvider, StaticRouterProvider, useRouterState, renderReactRouteMatch, and renderRouteBoundary
LinksLink, NavLink, active matching, prefetch, and native-browser preservation
Outlets, slots, and lazy viewsOutlet, Slot, slot-local error isolation, and lazyRouteView
HooksRouter state, navigation, URL state, blockers, outlet context, and route metadata
ContractsEvery exported React interface, type alias, and context value

Responsibility boundary

React receives already-resolved router state. Hooks such as useSearchParams() and useHashParams() do not reparse the browser URL and do not accept URL policy overrides. Configure those policies on routes, router creation, explicit router.match() calls, links, or navigation calls.

Where this bites

A React component can render perfectly while the route contract is wrong. Treat core validation and generated contracts as the authority; the React package is an adapter, not a second router.

On this page