Skip to content

Function: isAbsoluteRoute()

Documentation / @xmachines/play-xstate / isAbsoluteRoute

function isAbsoluteRoute(path): boolean;

Defined in: packages/play-xstate/src/routing/derive-route.ts:150

Check if route path is absolute

Determines whether a route path is absolute (starts with /) or relative. Absolute paths don’t inherit from parent routes, while relative paths can be composed with parent paths for nested routing.

Parameters

ParameterTypeDescription
pathstringRoute path to check

Returns

boolean

true if path starts with ’/’, false otherwise

Example

import { isAbsoluteRoute } from "@xmachines/play-xstate";
console.log(isAbsoluteRoute("/dashboard")); // true
console.log(isAbsoluteRoute("settings")); // false
console.log(isAbsoluteRoute("./about")); // false

See

deriveRoute for route extraction