Function: isRouteReachable()
API / @xmachines/play-router / isRouteReachable
function isRouteReachable(graph, fromStateId, toStateId): boolean;Defined in: query.ts:149
Check if a route is reachable from current state via transitions
Uses @statelyai/graph path-finding to determine if there exists a chain of transition edges from the source state to the target state.
Parameters
| Parameter | Type | Description |
|---|---|---|
graph | Graph<MachineNodeData, MachineEdgeData> | Machine graph from RouteTree.graph |
fromStateId | string | Source state ID |
toStateId | string | Target state ID |
Returns
boolean
true if a transition path exists, false otherwise
Example
const tree = extractMachineRoutes(machine);if (tree.graph) { const canReach = isRouteReachable(tree.graph, "auth.login", "auth.dashboard"); // true if login → dashboard transition path exists}