Skip to content

@isorouter/react

React adapter. Requires React ≥ 18. For a walkthrough see the React guide.

sh
npm install @isorouter/react

Exports

ExportKindDescription
createRouterfunctioncreateCoreRouter with the component type fixed to a React ComponentType.
RoutercomponentRoot component — calls start/stop, renders matched component or loading/notFound/error.
OutletcomponentRenders the next component in the matched chain; nothing if no child.
LinkcomponentA plain <a> intercepted by the Navigation API; forwards ref.
useRouterhookThe Router instance.
useRouterStatehookCurrent RouterSnapshot, re-rendering on every commit.
useParamshooksnapshot.params, typed as P.
useLocationhooksnapshot.url.
useNavigatehookReferentially-stable (to, opts?) => void.
lazyfunctionRe-exported from @isorouter/core.

Types

RouterProps, LinkProps, plus the core re-exports BeforeLoad, GuardContext, Href, NavTarget, RouteConfig, RouterOptions, RouterSnapshot.

<Router> props

PropTypeShown when
routerRouter instance
loadingReactNodeno matched root component yet; no error/notFound applies.
notFoundReactNodesnapshot.status === "not-found".
error(err: unknown) => ReactNodesnapshot.status === "error".

Extends AnchorHTMLAttributes<HTMLAnchorElement>. Adds href, activeClassName (default "active", appended to className) and exact. Sets aria-current="page" when active. See Links & active state.

Hooks

All must be used within <Router>. useNavigate() is referentially stable, so it's safe in dependency arrays without re-subscribing.

Bridge primitive: useSyncExternalStore(subscribe, getSnapshot) — detects change via Object.is(prev, next), which the immutable-snapshot contract satisfies with a fresh reference per commit.

Released under the MIT License.