Variable: extractMachineRoutes
Documentation / @xmachines/play-tanstack-react-router / extractMachineRoutes
const extractMachineRoutes: (machine) => RouteTree;Defined in: play-router/dist/extract-routes.d.ts:40
Extract complete route tree from state machine graph
Crawls machine starting from root, visits all state nodes (including nested and parallel), extracts meta.route metadata, validates route references, and builds hierarchical tree.
Parameters
| Parameter | Type | Description |
|---|---|---|
machine | AnyStateMachine | XState v5 state machine |
Returns
Route tree with root, byStateId map, and byPath map
Throws
If route references non-existent state
Throws
If route path is malformed (doesn’t start with /)
Throws
If parallel states define conflicting routes
Example
import { createMachine } from "xstate";import { extractMachineRoutes } from "@xmachines/play-router";
const machine = createMachine({ initial: "home", states: { home: { id: "home", meta: { route: "/" } }, dashboard: { id: "dashboard", meta: { route: "/dashboard" }, initial: "overview", states: { overview: { id: "overview", meta: { route: "/overview" } }, }, }, },});
const tree = extractMachineRoutes(machine);console.log(tree.byPath.get("/dashboard/overview"));