Skip to content

Function: buildRouteUrl()

Documentation / @xmachines/play-xstate / buildRouteUrl

function buildRouteUrl(routeTemplate, context?): string;

Defined in: packages/play-xstate/src/routing/build-url.ts:28

Build full URL from route template and context

Per CONTEXT.md:

  • “currentRoute derivation: Full URL generation including query params, hash, base path”
  • “Parameters: String template syntax — /user/:id”
  • “Inheritance: relative paths inherit parent route”

Per RESEARCH.md Pattern 3: Replace :param with context values

Parameters

ParameterTypeDescription
routeTemplatestringRoute path with :param placeholders
contextRouteContextRoute context with parameters, query, hash

Returns

string

Full URL string

Example

const url = buildRouteUrl("/user/:id", {
id: "123",
query: { tab: "profile" },
hash: "section-1",
});
// Result: '/user/123?tab=profile#section-1'