Skip to content

Class: ReactRouterBridge

Documentation / @xmachines/play-react-router / ReactRouterBridge

Defined in: play-react-router/src/react-router-bridge.ts:28

Abstract base class for all @xmachines router adapter bridges.

Implements RouterBridge protocol and contains all common bridge logic. Subclasses only need to implement the 3 abstract methods that differ between frameworks.

Extends

Constructors

Constructor

new ReactRouterBridge(
router,
actor,
routeMap): ReactRouterBridge;

Defined in: play-react-router/src/react-router-bridge.ts:31

Parameters

ParameterType
routerRouter$1
actorAbstractActor<AnyActorLogic> & Routable
routeMapRouteMap

Returns

ReactRouterBridge

Overrides

RouterBridgeBase.constructor

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
actorreadonlyAbstractActor<AnyActorLogic> & RoutableActor with currentRoute signal and send methodRouterBridgeBase.actorplay-router/dist/router-bridge-base.d.ts:55
hasConnectedOnceprotectedboolean-RouterBridgeBase.hasConnectedOnceplay-router/dist/router-bridge-base.d.ts:61
isConnectedprotectedboolean-RouterBridgeBase.isConnectedplay-router/dist/router-bridge-base.d.ts:60
isProcessingNavigationprotectedboolean-RouterBridgeBase.isProcessingNavigationplay-router/dist/router-bridge-base.d.ts:63
lastSyncedPathprotectedstring-RouterBridgeBase.lastSyncedPathplay-router/dist/router-bridge-base.d.ts:62
routeMapreadonlyobjectBidirectional route map for stateId ↔ path resolutionRouterBridgeBase.routeMapplay-router/dist/router-bridge-base.d.ts:56
routeMap.getPathByStateIdpublicstring | null | undefined--play-router/dist/router-bridge-base.d.ts:58
routeMap.getStateIdByPathpublicstring | null | undefined--play-router/dist/router-bridge-base.d.ts:57
routeWatcherprotected| Watcher | null-RouterBridgeBase.routeWatcherplay-router/dist/router-bridge-base.d.ts:64

Methods

connect()

connect(): void;

Defined in: 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

RouterBridgeBase.connect


disconnect()

disconnect(): void;

Defined in: 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

RouterBridgeBase.disconnect


extractParams()

protected extractParams(pathname, stateId): Record<string, string>;

Defined in: 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

ParameterTypeDescription
pathnamestringThe actual URL path (e.g., ‘/profile/john’)
stateIdstringThe 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: play-router/dist/router-bridge-base.d.ts:141

Extract query parameters from URL search string.

Parameters

ParameterTypeDescription
searchstringURL search string (e.g., ‘?tab=security&page=1’)

Returns

Record<string, string>

Extracted query parameters or empty object

Inherited from

RouterBridgeBase.extractQuery


getInitialRouterPath()

protected getInitialRouterPath(): string | null;

Defined in: play-react-router/src/react-router-bridge.ts:49

Return the router’s current pathname so connect() can sync the actor to the URL on initial load. router.subscribe() only fires on future navigations — it does not replay the already-loaded location — so without this, loading the page on /about would leave the actor in its default “home” state.

Returns

string | null

Overrides

RouterBridgeBase.getInitialRouterPath


protected navigateRouter(path): void;

Defined in: play-react-router/src/react-router-bridge.ts:39

Navigate the framework router to the given path.

Called when actor’s currentRoute signal changes to a new path. Must trigger the framework router’s navigation (e.g., router.navigate(path)).

Parameters

ParameterType
pathstring

Returns

void

Overrides

RouterBridgeBase.navigateRouter


syncActorFromRouter()

protected syncActorFromRouter(pathname, search?): void;

Defined in: 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

ParameterType
pathnamestring
search?string

Returns

void

Inherited from

RouterBridgeBase.syncActorFromRouter


syncRouterFromActor()

protected syncRouterFromActor(route): void;

Defined in: 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

ParameterType
routeunknown

Returns

void

Inherited from

RouterBridgeBase.syncRouterFromActor


unwatchRouterChanges()

protected unwatchRouterChanges(): void;

Defined in: play-react-router/src/react-router-bridge.ts:59

Stop watching for router location changes.

Called by disconnect(). Should clean up the framework-specific subscription.

Returns

void

Overrides

RouterBridgeBase.unwatchRouterChanges


watchRouterChanges()

protected watchRouterChanges(): void;

Defined in: play-react-router/src/react-router-bridge.ts:53

Start watching for router location changes.

Called by connect(). Should set up the framework-specific subscription for location changes and call syncActorFromRouter() on each change.

Returns

void

Overrides

RouterBridgeBase.watchRouterChanges