Class: SolidRouterBridge
Documentation / @xmachines/play-solid-router / SolidRouterBridge
Defined in: packages/play-solid-router/src/solid-router-bridge.ts:47
SolidJS Router integration bridge extending RouterBridgeBase
Implements RouterBridge protocol for SolidJS Router using Solid’s reactive primitives. The actor→router direction uses TC39 Signal watcher (from base class). The router→actor direction uses Solid’s createEffect for native reactivity.
Extends
Constructors
Constructor
new SolidRouterBridge( solidNavigate, location, _params, actor, routeMap): SolidRouterBridge;Defined in: packages/play-solid-router/src/solid-router-bridge.ts:59
Create a SolidJS Router bridge
CRITICAL: connect() must be called inside a Solid component where hooks are available.
Parameters
| Parameter | Type | Description |
|---|---|---|
solidNavigate | (path, …args) => unknown | Result of useNavigate() hook |
location | { pathname: string; search: string; } | Result of useLocation() hook |
location.pathname | string | - |
location.search | string | - |
_params | Record<string, string | undefined> | Result of useParams() hook |
actor | AbstractActor<AnyActorLogic> & Routable | XMachines actor instance |
routeMap | RouteMap | Bidirectional state ID ↔ path mapping |
Returns
SolidRouterBridge
Overrides
Properties
| Property | Modifier | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|---|
actor | readonly | AbstractActor<AnyActorLogic> & Routable | Actor with currentRoute signal and send method | RouterBridgeBase.actor | packages/play-router/dist/router-bridge-base.d.ts:55 |
hasConnectedOnce | protected | boolean | - | RouterBridgeBase.hasConnectedOnce | packages/play-router/dist/router-bridge-base.d.ts:61 |
isConnected | protected | boolean | - | RouterBridgeBase.isConnected | packages/play-router/dist/router-bridge-base.d.ts:60 |
isProcessingNavigation | protected | boolean | - | RouterBridgeBase.isProcessingNavigation | packages/play-router/dist/router-bridge-base.d.ts:63 |
lastSyncedPath | protected | string | - | RouterBridgeBase.lastSyncedPath | packages/play-router/dist/router-bridge-base.d.ts:62 |
routeMap | readonly | object | Bidirectional route map for stateId ↔ path resolution | RouterBridgeBase.routeMap | packages/play-router/dist/router-bridge-base.d.ts:56 |
routeMap.getPathByStateId | public | string | null | undefined | - | - | packages/play-router/dist/router-bridge-base.d.ts:58 |
routeMap.getStateIdByPath | public | string | null | undefined | - | - | packages/play-router/dist/router-bridge-base.d.ts:57 |
routeWatcher | protected | | Watcher | null | - | RouterBridgeBase.routeWatcher | packages/play-router/dist/router-bridge-base.d.ts:64 |
Methods
connect()
connect(): void;Defined in: packages/play-router/dist/router-bridge-base.d.ts:81
Connect the router bridge to the Actor.
Sets up the TC39 Signal watcher for actor → router direction and starts watching router changes (framework-specific).
Returns
void
Inherited from
disconnect()
disconnect(): void;Defined in: packages/play-router/dist/router-bridge-base.d.ts:87
Disconnect the router bridge from the Actor.
Stops signal watching and unregisters framework-specific router listener.
Returns
void
Inherited from
dispose()
dispose(): void;Defined in: packages/play-solid-router/src/solid-router-bridge.ts:123
Dispose the bridge (alias for disconnect).
Returns
void
Example
onCleanup(() => bridge.dispose());extractParams()
protected extractParams(pathname, stateId): Record<string, string>;Defined in: packages/play-router/dist/router-bridge-base.d.ts:134
Extract path parameters from URL using the URLPattern API.
Accesses globalThis.URLPattern at runtime — no polyfill is imported by this
library. If URLPattern is unavailable (Node.js < 24, older browsers without a
polyfill), this method returns {} silently (graceful degradation — routing still
works, params will be empty).
Parameters
| Parameter | Type | Description |
|---|---|---|
pathname | string | The actual URL path (e.g., ‘/profile/john’) |
stateId | string | The matched state ID for looking up route pattern |
Returns
Record<string, string>
Extracted path parameters, or empty object if URLPattern is unavailable or no match
Inherited from
RouterBridgeBase.extractParams
extractQuery()
protected extractQuery(search): Record<string, string>;Defined in: packages/play-router/dist/router-bridge-base.d.ts:141
Extract query parameters from URL search string.
Parameters
| Parameter | Type | Description |
|---|---|---|
search | string | URL search string (e.g., ‘?tab=security&page=1’) |
Returns
Record<string, string>
Extracted query parameters or empty object
Inherited from
getInitialRouterPath()
protected getInitialRouterPath(): string | null;Defined in: packages/play-solid-router/src/solid-router-bridge.ts:82
Get the current router pathname for initial URL -> actor sync on connect.
Returns
string | null
Overrides
RouterBridgeBase.getInitialRouterPath
navigateRouter()
protected navigateRouter(path): void;Defined in: packages/play-solid-router/src/solid-router-bridge.ts:75
Navigate SolidJS Router to the given path.
Parameters
| Parameter | Type |
|---|---|
path | string |
Returns
void
Overrides
RouterBridgeBase.navigateRouter
syncActorFromRouter()
protected syncActorFromRouter(pathname, search?): void;Defined in: packages/play-router/dist/router-bridge-base.d.ts:101
Sync actor state when router location changes.
Sends play.route event to actor with resolved stateId, params, and query. Prevents circular updates via isProcessingNavigation flag.
Parameters
| Parameter | Type |
|---|---|
pathname | string |
search? | string |
Returns
void
Inherited from
RouterBridgeBase.syncActorFromRouter
syncRouterFromActor()
protected syncRouterFromActor(route): void;Defined in: packages/play-router/dist/router-bridge-base.d.ts:94
Sync router location when actor route signal changes.
Calls navigateRouter() for framework-specific navigation. Prevents circular updates via isProcessingNavigation flag.
Parameters
| Parameter | Type |
|---|---|
route | unknown |
Returns
void
Inherited from
RouterBridgeBase.syncRouterFromActor
unwatchRouterChanges()
protected unwatchRouterChanges(): void;Defined in: packages/play-solid-router/src/solid-router-bridge.ts:111
Stop watching SolidJS Router changes.
Solid auto-cleans createEffect subscriptions when component unmounts.
Returns
void
Overrides
RouterBridgeBase.unwatchRouterChanges
watchRouterChanges()
protected watchRouterChanges(): void;Defined in: packages/play-solid-router/src/solid-router-bridge.ts:92
Subscribe to SolidJS Router location changes using createEffect.
MUST be called inside a Solid reactive owner (component/createRoot). Solid auto-cleans createEffect subscriptions on component unmount.
Returns
void