Function: connectRouter()
API / @xmachines/play-dom-router / connectRouter
function connectRouter(options): RouterConnection;Defined in: play-dom-router/src/connect-router.ts:54
Connects the vanilla router to an actor. This is a pure browser integration.
The function returns a CALLABLE handle: call it to stop the synchronization, as
before. The handle also carries the mount — basePath, basePathParams and
setBasePath() — because the bridge itself stays inside this function.
Parameters
| Parameter | Type |
|---|---|
options | ConnectRouterOptions |
Returns
Example
import { createBrowserHistory, createRouter, connectRouter, createRouteMap,} from "@xmachines/play-dom-router";import { extractMachineRoutes } from "@xmachines/play-router";
const routeTree = extractMachineRoutes(machine);const routeMap = createRouteMap(machine);const history = createBrowserHistory({ window });const router = createRouter({ routeTree, history });const disconnect = connectRouter({ actor, router, routeMap });// Later:disconnect();