Advanced API reference
Low-level and advanced APIs for @aurelia/router (router-lite).
Instruction trees (ViewportInstructionTree)
ViewportInstructionTree)Create an instruction tree
import { IRouter } from '@aurelia/router';
import { resolve } from '@aurelia/kernel';
const router = resolve(IRouter);
const instructions = router.createViewportInstructions('users');Convert an instruction tree to a path or URL
import { IRouter, IRouterEvents, type NavigationStartEvent } from '@aurelia/router';
import { resolve } from '@aurelia/kernel';
export class NavigationLogger {
private readonly router = resolve(IRouter);
public constructor() {
resolve(IRouterEvents).subscribe('au:router:navigation-start', (event: NavigationStartEvent) => {
// Instruction path (example: 'users+details@right')
console.log('toPath:', event.instructions.toPath());
// URL string (example: '/users+details@right')
console.log(
'toUrl:',
event.instructions.toUrl(false, this.router.options._urlParser, true),
);
});
}
}Path generation (router.generatePath)
router.generatePath)Active state checks (router.isActive)
router.isActive)Route tree and transitions
Managed browser history state (AuNavId / ManagedState)
AuNavId / ManagedState)Last updated
Was this helpful?