ReferencePackages
@mwillbanks/tuil-router
Typed terminal routes, guards, history, loaders, layouts, and focus restoration for tuil.
Overview
Typed terminal routes, guards, history, loaders, layouts, and focus restoration for tuil.
@mwillbanks/tuil-router is independently installable and also participates in the
umbrella @mwillbanks/tuil runtime where applicable.
Installation
npm install @mwillbanks/tuil-routerHow it operates
The terminal router matches typed routes, executes guards and loaders, manages history and layouts, exposes navigation surfaces, and restores focus after transitions.
API
| API | Signature | Description |
|---|---|---|
createRouter | function createRouter | Public function createRouter. |
defineRoutes | function defineRoutes | Public function defineRoutes. |
FocusSnapshot | interface FocusSnapshot | Public interface FocusSnapshot. |
NavigationEntry | interface NavigationEntry | Public interface NavigationEntry. |
NavigationSurface | type NavigationSurface | Public type NavigationSurface. |
NavigationTarget | type NavigationTarget | Public type NavigationTarget. |
route | function route | Public function route. |
RouteContext | interface RouteContext | Public interface RouteContext. |
RouteDefinition | interface RouteDefinition | Public interface RouteDefinition. |
RouteMatch | interface RouteMatch | Public interface RouteMatch. |
RouterEvent | interface RouterEvent | Public interface RouterEvent. |
RouterEventType | type RouterEventType | Public type RouterEventType. |
RouterState | interface RouterState | Public interface RouterState. |
TerminalRouter | class TerminalRouter | Public class TerminalRouter. |
TerminalRouterOptions | interface TerminalRouterOptions | Public interface TerminalRouterOptions. |
Events and lifecycle
router:navigation-start, router:navigation-complete, router:navigation-cancel, and router:navigation-error describe transition outcomes.
All subscriptions and registrations return a disposer or belong to an owning runtime that disposes them in reverse order.
Example
import { createRouter, defineRoutes, route } from "@mwillbanks/tuil-router";
const router = createRouter(defineRoutes({ home: route({ path: "/" }) }));
await router.navigate("home");