Function: createRouter()
API / @xmachines/play-dom-router / createRouter
function createRouter(options): VanillaRouter;Defined in: play-dom-router/src/create-router.ts:52
Create vanilla router for framework-agnostic routing.
Architecture:
- Just wraps history and routeTree
- Does NOT embed routeMap (providers need it as prop)
- Framework-agnostic history management only
Why no routeMap:
- Router doesn’t know about state IDs (that’s Play-specific)
- RouteMap is the bridge between router and actor
- Provider receives routeMap as prop to do path → state ID resolution
Usage (parallel to TanStack mode):
// Both modes: identical setupconst routeTree = extractMachineRoutes(machine);const routeMap = createRouteMapFromTree(routeTree);const history = createBrowserHistory({ window });
// Vanilla routerconst router = createRouter({ routeTree, history });
// Connect router to actor (handles all bidirectional sync)const disconnect = connectRouter({ actor, router, routeMap });
// Later: cleanupdisconnect();router.destroy();Parameters
| Parameter | Type |
|---|---|
options | { history: BrowserHistory; routeTree: RouteTree; } |
options.history | BrowserHistory |
options.routeTree | RouteTree |