glossary - greydragon888/real-router GitHub Wiki
Quick reference for terms used throughout the Real Router documentation.
A standard Web API signal passed to navigate() via NavigationOptions that lets you cancel an in-flight navigation from outside the router. When the signal aborts, the transition is cancelled and the router returns to READY.
See: NavigationOptions, navigation-lifecycle
A guard function that runs when a route is being entered. Returns true to allow the transition, or any falsy value to block it. Can be async.
See: addActivateGuard, Guards
A function registered via addInterceptor("buildPath", fn) on the Plugin API that transforms params in the buildPath pipeline. Multiple interceptors execute in LIFO order (last-registered wraps first). Used by plugins to inject or modify URL parameters without monkey patching.
See: Plugin Architecture — Plugin Interception
The built-in plugin that synchronizes router state with the browser's History API. Reads the current URL on start(), updates the URL on every successful navigation, and listens for popstate events (back/forward buttons).
See: browser-plugin, Plugin Architecture
The act of aborting an in-flight navigation before it completes. Triggered by starting a new navigate() call while one is already running, calling stop(), or passing an AbortSignal that fires. The cancelled transition rejects with a TRANSITION_CANCELLED error code.
See: navigation-lifecycle, error-codes
A guard function that runs when a route is being left. Returns true to allow the transition, or any falsy value to block it. Useful for "unsaved changes" prompts.
See: addDeactivateGuard, Guards
A route config option that provides fallback parameter values when the URL doesn't supply them. Merged into state.params whenever the route is active.
See: Route
The pattern Real Router uses to share services (auth, store, API clients) with guards and plugins. You register values with setDependency and retrieve them with getDependency inside guard factories and plugin factories.
See: getDependency, setDependency
A method on the Plugin API that formally adds properties to the router instance. Performs conflict detection (throws PLUGIN_CONFLICT if a key already exists) and returns an unsubscribe function for cleanup. Used by the browser-plugin to add buildUrl, matchUrl, and replaceHistoryState.
See: extendRouter, Plugin Architecture
How the router evaluates guard return values. It uses !result — so undefined, null, 0, "", and false all block navigation. Only a truthy value (typically true) allows the transition through.
See: Guards
A route config option that redirects navigation to another route before guards run. Accepts a static route name string or a callback (getDependency, params) => string for dynamic redirects. Guards on the source route are skipped; only guards on the destination run.
See: Route, navigation-lifecycle
The model that governs the router's lifecycle. At any moment the router is in exactly one state: IDLE, STARTING, READY, TRANSITION_STARTED, LEAVE_APPROVED, or DISPOSED. Transitions between these states are triggered by start(), stop(), navigate(), and dispose().
See: core-concepts
A function that can allow or block a navigation transition. Returns true to allow, or any falsy value to block. Guards can be synchronous or return a Promise. They run before state changes and before plugins are notified.
See: Guards, addActivateGuard, addDeactivateGuard
An FSM state entered after all canDeactivate guards pass and before canActivate guards run. The route has not yet changed, but departure is confirmed. subscribeLeave() callbacks and the onTransitionLeaveApprove plugin hook fire during this phase.
See: core-concepts, subscribeLeave
The callback type for subscribeLeave(). Signature: (state: LeaveState) => void.
See: subscribeLeave, LeaveState
The argument passed to LeaveFn callbacks. Shape: { route: State; nextRoute: State }, where route is the route being left and nextRoute is the destination.
See: subscribeLeave
A method on a plugin object that the router calls at specific points in its lifecycle. Available hooks include onStart, onStop, onTransitionStart, onTransitionSuccess, onTransitionError, onTransitionCancel, and onTransitionLeaveApprove.
See: plugin-architecture
The options object passed as the second argument to navigate(). Controls behavior like replace (replace history entry instead of push), reload (force re-navigation to the current route), force (bypass same-state check), forceDeactivate (skip canDeactivate guards), and signal (AbortSignal for cancellation).
See: NavigationOptions
A synonym for Segment. Used especially in the context of view subscriptions with useRouteNode, where you subscribe a component to a specific node in the route tree.
See: useRouteNode, core-concepts
A plugin lifecycle hook that fires during the LEAVE_APPROVED phase. Use it for plugin-level side effects tied to confirmed route departure — for example, flushing analytics or releasing locks before the new route activates.
See: plugin-architecture, LEAVE_APPROVED
The URL pattern language used in route path definitions. Supports :param (required segment), :param? (optional segment), *splat (catch-all), ?query (query parameter), ;matrix (matrix parameter), ~ prefix (absolute path ignoring parent), and <constraint> (regex constraint on a parameter).
See: Route
An observer object that reacts to router lifecycle events. Plugins cannot block navigation — they only observe. Created via a Plugin Factory and registered with usePlugin().
See: plugin-architecture, usePlugin
A function with the signature (router, getDependency) => Plugin that creates a plugin instance. The factory receives the router and a DI accessor, so plugins can access shared services without tight coupling.
See: plugin-architecture
A named destination in your application, defined by a name and a URL path pattern. Routes can have children (nested routes), guards, forwardTo redirects, defaultParams, and custom param encoders.
See: Route, core-concepts
The hierarchical structure of all registered routes, organized by dot-separated names. users.profile means profile is a child of users. The tree determines which segments activate and deactivate during each navigation.
See: core-concepts
The error object thrown when a navigation fails or is blocked. Contains a code field (string) and optional fields like segment, path, and redirect. Use the error-codes reference to handle specific failure cases.
See: RouterError, error-codes
A single node in the route tree. The route name users.profile contains two segments: users and users.profile. During navigation, the router calculates which segments to deactivate and which to activate.
See: core-concepts
An immutable snapshot of the current router location. Contains name (active route name), params (URL and query parameters), and path (resolved URL string). Frozen with Object.freeze() — never mutated in place.
See: State, core-concepts
A callback registered with subscribe() that is called after every successful navigation. Receives the new state and the previous state. Returns an unsubscribe function.
See: subscribe
router.subscribeLeave(listener: LeaveFn): Unsubscribe — Subscribe to confirmed route departures. The callback fires during the LEAVE_APPROVED phase, after canDeactivate guards pass and before canActivate guards run. Returns an unsubscribe function.
See: subscribeLeave, LeaveFn, LeaveState
The cleanup hook called on a plugin when it is removed or when the router is disposed. Use it to clear timers, remove event listeners, or release any resources the plugin holds.
See: plugin-architecture
The process of moving from one router state to another. Includes calculating the transition path, running deactivate guards, running activate guards, updating state, and notifying plugins and subscribers.
See: navigation-lifecycle, core-concepts
The deepest common ancestor segment where two routes diverge. Segments below the intersection on the current route get deactivated; segments below it on the target route get activated. Segments at or above the intersection stay mounted.
See: core-concepts
The calculated set of segments to deactivate and activate during a navigation. Computed from the current state and the target state by finding the Transition Node and walking the tree in both directions.
See: navigation-lifecycle
The internal event name ("$$leaveApprove") for the router event fired when LEAVE_APPROVED is entered. Listen via getPluginApi(router).addEventListener(events.TRANSITION_LEAVE_APPROVE, ...).
See: addEventListener, LEAVE_APPROVED
A special route name ("@@router/UNKNOWN_ROUTE") used when the router cannot match a URL to any registered route.
Unlike regular routes, UNKNOWN_ROUTE is not registered in the route tree.
Set programmatically via navigateToNotFound() or automatically during start() / popstate when allowNotFound: true.
Import the constant from @real-router/core:
import { UNKNOWN_ROUTE } from "@real-router/core";See: navigateToNotFound, State