Skip to content

Interface: BasePathOptions

API / @xmachines/play-dom-router / BasePathOptions

Defined in: play-url/src/base-path.ts:44

The base-path options that every router bridge, connectRouter function, and PlayRouterProvider component accepts.

Example

// A host that mounts a machine under a route it resolved in a loader
connectRouter({
actor,
router,
routeMap,
basePath: "/:machineId/play",
basePathParams: { machineId },
});

Extended by

Properties

PropertyModifierTypeDescriptionDefined in
basePath?readonlystringThe URL prefix that the routes of the machine hang off, for example "/admin" or "/:machineId/play". A :param segment is a declarative convenience, so that a host keeps ONE string that mirrors its own route config. Every :param must have a value in BasePathOptions.basePathParams, because the bridge writes a real URL. An optional segment (:param?) and a wildcard (*) are therefore refused: neither of them resolves to one concrete prefix. An absent value, "", and "/" all mean “no prefix”, which is the behaviour of every release before this option existed.play-url/src/base-path.ts:58
basePathParams?readonlyRecord<string, string | number>The values of the :param segments of BasePathOptions.basePath. These values belong to the HOST, which wrote the prefix and resolved them, so they travel in NO play.route event: the machine is authoritative over its own params, and event.params holds what the pattern of the machine declares, and nothing else. A param of the host that shares a name with one of the machine can therefore shadow it never. A host reads them back from bridge.basePathParams, where they cannot go stale. A machine that needs the identity of its host takes it through the input of the actor, where that identity decides WHICH machine runs.play-url/src/base-path.ts:72