Skip to content

Function: getTransitionReachableRoutes()

API / @xmachines/play-router / getTransitionReachableRoutes

function getTransitionReachableRoutes(graph, stateId): string[];

Defined in: query.ts:154

Get routes reachable via transitions from current state

Uses the @statelyai/graph successor algorithm to find all states directly reachable via transition edges from the given state, then filters to those with defined routes.

Returned values are the RAW meta.route strings from the machine — relative routes (e.g. "detail") are NOT resolved to full paths and cannot be used as tree.byPath keys. For resolved RouteNodes use getNavigableRoutes, which resolves reachable states through tree.byStateId.

Parameters

ParameterTypeDescription
graphGraph<MachineNodeData, MachineEdgeData>Machine graph from RouteTree.graph
stateIdstringCurrent state ID (e.g., “test.home”)

Returns

string[]

Array of raw route strings reachable via transitions

Example

const tree = extractMachineRoutes(machine);
if (tree.graph) {
const reachable = getTransitionReachableRoutes(tree.graph, "auth.loggedIn");
// ['/dashboard', '/settings'] — routes reachable via transitions
}