Skip to content

Interface: PlayRouterProviderBaseProps<TRouter, TActor, TNode>

API / @xmachines/play-router / index / PlayRouterProviderBaseProps

Defined in: packages/play-router/src/provider-lifecycle.ts:37

The props that every PlayRouterProvider of a framework shares.

TNode is what the framework renders: ReactNode for React, JSX.Element for Solid. It is the ONLY thing in these props that a framework decides, which is why they live here and not in an adapter.

An adapter re-exports a two-parameter alias of this type, with TRouter bound to the type of its router instance and TNode bound to its own node type.

Extends

Type Parameters

Type Parameter
TRouter
TActor extends RoutableActor
TNode

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
actorpublicTActorThe actor to keep in step with the router. It must be a stable reference: give the same actor instance on every render. An actor in the JSX, or a new actor on each render, makes the bridge disconnect and connect again each time.-packages/play-router/src/provider-lifecycle.ts:47
basePath?publicstringMounts the routes of the machine under a URL prefix that the host owns, so that the routes of the host and the routes of the machine share one router. actor, router, and routeMap each need a stable reference. This prop needs none, and it rebuilds the bridge never: a change moves the live bridge with setBasePath(), so a host route that renders again with a new prefix keeps the actor, the route map, and its cache. The prefix says WHERE an actor is mounted, and never WHICH actor is mounted. An actor never changes identity, so a prefix segment that IDENTIFIES the actor gives a different actor prop instead, and THAT rebuilds the bridge — which is correct, because one actor takes one bridge. A location outside the prefix belongs completely to the host: the bridge sends no event there, and it corrects no URL there. Every :param needs a value. An unresolved one throws a MissingBasePathParamError out of the mount effect, because the bridge writes no URL without it. Render this component only after the host holds the value, which a route loader or a useParams() call does already.-packages/play-router/src/provider-lifecycle.ts:85
basePathParams?publicRecord<string, string | number>The values of the :param segments of PlayRouterProviderBaseProps.basePath, for example { machineId } for basePath="/:machineId/play". An inline object literal is correct here: the provider compares this prop by value, and a move to the same prefix does nothing.-packages/play-router/src/provider-lifecycle.ts:94
compiledCache?readonlyPatternCache<URLPatternLike>The cache of the COMPILED URLPattern, which is what this function returns. The default is a cache that this module shares with every caller of the process. Pass one to give a tenant or a request a compilation that no other evicts, and pass { get: () => undefined, set: () => {} } to compile each time. A caller that passes patternCache for isolation passes this one too. The compiled cache is read FIRST, so a hit on it answers before the parse runs at all — a passed parse cache alone therefore isolates nothing once another caller has compiled the same pattern.CompileOptions.compiledCachepackages/play-url/src/url-pattern-utils.ts:119
patternCache?readonlyPatternCache<ParsedPattern>The cache of the PARSE of a pattern. The default is the cache that this package shares with every caller of the process.CompileOptions.patternCachepackages/play-pattern/src/cache.ts:40
rendererpublic(actor, router) => TNodeThe renderer callback receives the same concrete actor type as the prop.-packages/play-router/src/provider-lifecycle.ts:96
routeMappublicRouteMapThe route map of both directions, for the lookup between a state ID and a URL path. It must be a stable reference. The provider builds the bridge again on each change of the identity of routeMap. A value in the JSX, for example createRouteMapFromTree(routeTree), makes a new object on every render, and the bridge therefore connects again on every render. Hold the value with useMemo: const routeMap = useMemo(() => createRouteMapFromTree(routeTree), [routeTree]);-packages/play-router/src/provider-lifecycle.ts:62
routerpublicTRouterThe router instance that the bridge keeps in step with the actor. It must be a stable reference.-packages/play-router/src/provider-lifecycle.ts:49