The Route class represents a resolved route object in @esmx/router. Each navigation produces a Route instance containing complete information about the matched path, parameters, query strings, and associated metadata.
enum RouteType {
push = 'push',
replace = 'replace',
restartApp = 'restartApp',
go = 'go',
forward = 'forward',
back = 'back',
unknown = 'unknown',
pushWindow = 'pushWindow',
replaceWindow = 'replaceWindow',
pushLayer = 'pushLayer'
}Indicates how the navigation was triggered:
push: Standard forward navigation (adds history entry)replace: Replaces current history entryrestartApp: App restart navigationgo: Programmatic history traversal via router.go()forward: Forward navigation via router.forward()back: Backward navigation via router.back()unknown: Navigation triggered by browser popstate eventspushWindow: Opens navigation in a new windowreplaceWindow: Replaces current window locationpushLayer: Opens navigation in a layerinterface 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 used for programmatic navigation:
path: Route pathurl: Full URL string or URL objectparams: Route parameters for dynamic segmentsquery: Query string parameters (single values)queryArray: Query string parameters (array values for repeated keys)hash: URL hash fragmentstate: Custom state data persisted in historykeepScrollPosition: When true, maintains current scroll position after navigationstatusCode: HTTP status code for server-side responseslayer: Layer configuration optionsconfirm: Custom confirm handler overriding default route transition logictype RouteLocationInput = RouteLocation | string;Input type for navigation methods. Can be a simple path string or a RouteLocation object.
// String shorthand
router.push('/user/123');
// Object form
router.push({
path: '/user',
query: { id: '123' },
hash: '#profile'
});RouteTypetrueThe navigation type that created this route.
stringtrueThe path relative to the router base. For matched routes, this is the path with the base prefix removed. For unmatched routes, this equals the full pathname.
// With base URL 'https://example.com/app/'
// Navigating to '/app/user/123'
route.path // '/user/123'stringtrueThe complete path including query string and hash.
route.fullPath // '/user/123?tab=profile#bio'URLtrueThe full URL object for this route.
route.url.href // 'https://example.com/app/user/123?tab=profile#bio'
route.url.pathname // '/app/user/123'
route.url.origin // 'https://example.com'Record<string, string>trueDynamic route parameters extracted from the path. For parameters with multiple matches, contains the first value.
// Route config: { path: '/user/:id' }
// URL: '/user/123'
route.params // { id: '123' }Record<string, string[]>trueDynamic route parameters in array form, useful for parameters that can match multiple segments.
Record<string, string | undefined>trueParsed query string parameters. For repeated keys, contains the first value.
// URL: '/search?q=vue&page=1'
route.query // { q: 'vue', page: '1' }Record<string, string[] | undefined>trueQuery string parameters in array form, useful for repeated query keys.
// URL: '/filter?tag=vue&tag=react'
route.queryArray // { tag: ['vue', 'react'] }stringtrueThe URL hash fragment (including the # prefix).
// URL: '/page#section-2'
route.hash // '#section-2'RouteMetatrueRoute metadata from the matched route configuration. Returns an empty object if no route is matched.
// Route config: { path: '/admin', meta: { requiresAuth: true } }
route.meta // { requiresAuth: true }readonly RouteParsedConfig[]trueArray of matched route configurations from parent to child. Empty array if no route matches.
// Nested routes: /user/profile
route.matched // [userConfig, profileConfig]
route.matched.length // 2RouteParsedConfig | nulltrueThe last (deepest) matched route configuration. null if no route matches.
if (route.config) {
console.log('Matched route path:', route.config.path);
}RouteStatetrueCustom state data associated with this route, persisted in browser history.
// Navigation with state
router.push({ path: '/checkout', state: { cartId: 'abc' } });
// Accessing state
route.state // { cartId: 'abc' }booleantrueWhether the navigation should maintain the current scroll position rather than scrolling to top.
booleantrueWhether this route was created by a push-type navigation (push, pushWindow, pushLayer).
number | nulltrueHTTP status code for server-side rendering redirects.
IncomingMessage | nulltrueNode.js HTTP request object (available during SSR).
ServerResponse | nulltrueNode.js HTTP response object (available during SSR).
Record<string | symbol, any>trueShared context object from the router options.
RouteCreates a copy of the current route instance with the same configuration and state.
const routeCopy = route.clone();