Skip to content

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

ParameterTypeDescription
graphGraph<MachineNodeData, MachineEdgeData>Machine graph from RouteTree.graph
fromStateIdstringSource state ID
toStateIdstringTarget 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
}