Skip to content

@gluonjs/core / packages/router/src / RouteLocationNormalized

Interface: RouteLocationNormalized ​

Properties ​

data ​

readonly data: RouteData

Merged static route-record data; loaders and network clients stay application-owned.


fullPath ​

readonly fullPath: string


hash ​

readonly hash: string


href ​

readonly href: string


matched ​

readonly matched: readonly RouteRecordNormalized[]


meta ​

readonly meta: RouteMeta


name? ​

readonly optional name?: string


params ​

readonly params: RouteParams


path ​

readonly path: string


query ​

readonly query: LocationQuery


redirectedFrom? ​

readonly optional redirectedFrom?: RouteLocationNormalized


state ​

readonly state: HistoryState

Example ​

Read the canonical path, href, query, hash, parameters, metadata, matches, and state produced by Router resolution:

ts
import {
  NavigationFailureType,
  createMemoryHistory,
  createRouter,
  isNavigationFailure,
  type AfterNavigationHook,
  type NavigationFailure,
  type NavigationFailureTypeValue,
  type NavigationGuard,
  type NavigationGuardReturn,
  type RouteLocationNormalized,
  type RouteLocationPath,
  type RouteLocationRaw,
  type Router,
  type RouterSnapshot,
  type ScrollBehavior,
} from '@gluonjs/router';

const target = { path: '/checkout', query: { step: 2 } } satisfies RouteLocationPath;
const rawTarget: RouteLocationRaw = target;
const guardResult: NavigationGuardReturn = true;
const requireCart: NavigationGuard = (to: RouteLocationNormalized) =>
  to.path === '/checkout' ? guardResult : true;
const restoreScroll: ScrollBehavior = (_to, _from, savedPosition) =>
  savedPosition ?? { left: 0, top: 0 };
const afterEach: AfterNavigationHook = (to, from, failure?: NavigationFailure) =>
  console.log(`${from.fullPath} -> ${to.fullPath}`, failure?.message);

const router: Router = createRouter({
  history: createMemoryHistory(['/shop']),
  routes: [{ path: '/shop' }, { path: '/checkout' }],
  scrollBehavior: restoreScroll,
});
const stopGuard = router.beforeEach(requireCart);
const stopAfter = router.afterEach(afterEach);
const failure = await router.push(rawTarget);
const failureType: NavigationFailureTypeValue = NavigationFailureType.aborted;
if (isNavigationFailure(failure, failureType)) console.warn(failure.to.fullPath);
const snapshot: RouterSnapshot = router.dehydrate();
console.log(snapshot.location, router.currentRoute.value.fullPath);
stopGuard();
stopAfter();
router.destroy();

Version-matched documentation. Examples are checked against the public package contracts.