Function: findRouteByPath()
Documentation / @xmachines/play-router / findRouteByPath
function findRouteByPath(tree, path): RouteNode | undefined;Defined in: index.ts:161
Find route node by URL path
Looks up route node using the URL path. Used to get state ID from browser URL for sending play.route events on navigation.
When multiple states share the same path (e.g., root and a state both at ”/”), prefers routable nodes (with meta.route) over non-routable nodes.
Supports pattern matching for dynamic routes (e.g., ‘/settings/:section?’).
Parameters
| Parameter | Type | Description |
|---|---|---|
tree | RouteTree | Route tree from extractMachineRoutes |
path | string | URL path (e.g., ‘/dashboard’, ‘/settings/profile’) |
Returns
RouteNode | undefined
Route node if found, undefined otherwise
Example
const tree = extractMachineRoutes(machine);const node = findRouteByPath(tree, "/dashboard");