This page provides a comprehensive listing of all types exported by @esmx/router and @esmx/router-vue.
enum RouterMode {
history = 'history',
memory = 'memory'
}Router operation mode:
history: Uses browser History APImemory: Uses in-memory history stackenum RouteType {
push = 'push',
replace = 'replace',
restartApp = 'restartApp',
go = 'go',
forward = 'forward',
back = 'back',
unknown = 'unknown',
pushWindow = 'pushWindow',
replaceWindow = 'replaceWindow',
pushLayer = 'pushLayer'
}Navigation type that triggered the route creation. See Route for details.
type RouteMeta = Record<string | symbol, unknown>;Custom route metadata type. Used to attach arbitrary data to route configurations that is accessible via route.meta.
const routes = [
{
path: '/admin',
meta: {
requiresAuth: true,
title: 'Admin Panel',
[Symbol('internal')]: 'data'
}
}
];type RouteState = Record<string, unknown>;Route state type. Used for persisting custom data in the browser's history state.
router.push({
path: '/page',
state: { scrollY: 100, formData: { name: 'John' } }
});type RouteHandleResult = unknown | null | void;Return type of route handle hooks. The result is accessible via route.handleResult.
type RouteMatchType = 'route' | 'exact' | 'include';Route matching strategy:
'route': Route-level matching — compares whether route configurations are the same'exact': Exact matching — compares whether paths are exactly the same'include': Include matching — checks whether the current path contains the target pathtype Awaitable<T> = T | Promise<T>;Utility type representing a value that can be either synchronous or a Promise.
interface RouteLocation {
path?: string;
url?: string | URL;
params?: Record<string, string>;
query?: Record<string, string | undefined>;
queryArray?: Record<string, string[] | undefined>;
hash?: string;
state?: RouteState;
keepScrollPosition?: boolean;
statusCode?: number | null;
layer?: RouteLayerOptions | null;
confirm?: RouteConfirmHook | null;
}Route location object for navigation. See Route for details.
type RouteLocationInput = RouteLocation | string;Input type for navigation methods. Can be a string path or a RouteLocation object.
interface RouteConfig {
path: string;
component?: unknown;
children?: RouteConfig[];
redirect?: RouteLocationInput | RouteConfirmHook;
meta?: RouteMeta;
app?: string | RouterMicroAppCallback;
asyncComponent?: () => Promise<unknown>;
beforeEnter?: RouteConfirmHook;
beforeUpdate?: RouteConfirmHook;
beforeLeave?: RouteConfirmHook;
layer?: boolean;
override?: RouteConfirmHook;
}Route configuration interface. See Route Configuration for details.
interface RouteParsedConfig extends RouteConfig {
compilePath: string;
children: RouteParsedConfig[];
match: MatchFunction;
compile: (params?: Record<string, string>) => string;
}Internal parsed route configuration with compiled matching and compilation functions.
interface RouteMatchResult {
readonly matches: readonly RouteParsedConfig[];
readonly params: Record<string, string | string[]>;
}Result of route matching operations.
type RouteMatcher = (
to: URL,
base: URL,
cb?: (item: RouteParsedConfig) => boolean
) => RouteMatchResult;Route matching function type.
type RouteConfirmHook = (
to: Route,
from: Route | null,
router: Router
) => Awaitable<RouteConfirmHookResult>;Confirmation guard that can approve, cancel, or redirect navigation.
type RouteConfirmHookResult =
| void
| false
| RouteLocationInput
| RouteHandleHook;Return type for confirmation hooks.
type RouteNotifyHook = (
to: Route,
from: Route | null,
router: Router
) => void;Notification hook called after navigation completes.
type RouteVerifyHook = (
to: Route,
from: Route | null,
router: Router
) => Awaitable<boolean>;Verification hook returning a boolean result.
type RouteHandleHook = (
to: Route,
from: Route | null,
router: Router
) => Awaitable<RouteHandleResult>;Handle hook for custom route handling logic.
interface RouterOptions {
root?: string | HTMLElement;
context?: Record<string | symbol, unknown>;
data?: Record<string | symbol, unknown>;
routes?: RouteConfig[];
mode?: RouterMode;
base?: URL;
req?: IncomingMessage | null;
res?: ServerResponse | null;
apps?: RouterMicroApp;
normalizeURL?: (to: URL, from: URL | null) => URL;
fallback?: RouteHandleHook;
nextTick?: () => Awaitable<void>;
rootStyle?: Partial<CSSStyleDeclaration> | false | null;
layer?: boolean;
zIndex?: number;
handleBackBoundary?: (router: Router) => void;
handleLayerClose?: (router: Router, data?: any) => void;
}Router constructor options. See Router for details.
interface RouterParsedOptions extends Readonly<Required<RouterOptions>> {
readonly compiledRoutes: readonly RouteParsedConfig[];
readonly matcher: RouteMatcher;
}Fully parsed and resolved router options with compiled routes and matcher.
type RouterLinkType =
| 'push'
| 'replace'
| 'pushWindow'
| 'replaceWindow'
| 'pushLayer';Navigation types for links.
interface RouterLinkProps {
to: RouteLocationInput;
type?: RouterLinkType;
replace?: boolean;
exact?: RouteMatchType;
activeClass?: string;
event?: string | string[];
tag?: string;
layerOptions?: RouteLayerOptions;
beforeNavigate?: (event: Event, eventName: string) => void;
}Link configuration properties. See RouterLink for details.
interface RouterLinkAttributes {
href: string;
class: string;
target?: '_blank';
rel?: string;
}HTML attributes generated for link elements.
interface RouterLinkResolved {
route: Route;
type: RouterLinkType;
isActive: boolean;
isExactActive: boolean;
isExternal: boolean;
tag: string;
attributes: RouterLinkAttributes;
navigate: (e: Event) => Promise<void>;
createEventHandlers: (
format?: (eventType: string) => string
) => Record<string, (e: Event) => Promise<void>>;
}Resolved link data. See RouterLink for details.
interface RouteLayerOptions {
zIndex?: number;
keepAlive?: 'exact' | 'include' | RouteVerifyHook;
shouldClose?: RouteVerifyHook;
autoPush?: boolean;
push?: boolean;
routerOptions?: RouterLayerOptions;
}Layer creation options. See Layer Routing for details.
type RouteLayerResult =
| { type: 'close'; route: Route }
| { type: 'push'; route: Route }
| { type: 'success'; route: Route; data?: any };Layer result discriminated union. See Layer Routing for details.
type RouterLayerOptions = Omit<
RouterOptions,
'handleBackBoundary' | 'handleLayerClose' | 'layer'
>;Router options for layer creation, excluding internally managed handler fields.
type RouterMicroApp =
| Record<string, RouterMicroAppCallback | undefined>
| RouterMicroAppCallback;Micro-app configuration. Can be either a named map of app factories or a single factory function.
type RouterMicroAppCallback = (router: Router) => RouterMicroAppOptions;Factory function that creates a micro-app instance from a router.
interface RouterMicroAppOptions {
mount: (el: HTMLElement) => void;
unmount: () => void;
renderToString?: () => Awaitable<string>;
}Micro-app lifecycle interface:
mount: Mount the app into a DOM elementunmount: Unmount and clean up the apprenderToString: Optional SSR render methodinterface RouteOptions {
options?: RouterParsedOptions;
toType?: RouteType;
toInput?: RouteLocationInput;
from?: URL | null;
}Constructor options for the Route class (internal use).
The following types are deprecated and will be removed in a future version:
/** @deprecated Use `Router` directly instead */
type RouterInstance = Router;/** @deprecated Use `RouteLocationInput` directly instead */
type RouterRawLocation = RouteLocationInput;/** @deprecated Use `RouteLocation` directly instead */
type RouterLocation = RouteLocation;/** @deprecated Use `Route` directly instead */
type RouteRecord = Route;