Child routing playbook
Build deeply nested navigation trees with Aurelia's router, including layouts, sibling viewports, and relative navigation.
1. Define parent and child routes
import { route } from '@aurelia/router';
import { UsersPage } from './users/users-page';
import { ReportsPage } from './reports/reports-page';
@route({
routes: [
{ path: '', component: UsersPage, title: 'Users' },
{ path: 'reports', component: ReportsPage, title: 'Reports' },
]
})
export class AdminLayout {}import { route } from '@aurelia/router';
import { UserOverview } from './user-overview';
import { UserSettings } from './user-settings';
@route({
routes: [
{ path: ':id', component: UserOverview, title: 'Overview' },
{ path: ':id/settings', component: UserSettings, title: 'Settings' },
]
})
export class UsersPage {}2. Render child viewports in parent templates
3. Share layout data across child routes
4. Navigate within the current hierarchy
5. Combine child routes with parameters
6. Lazy-load nested modules
7. Test nested layouts in isolation
Scenario recipes
Tabs inside a detail page
Protected admin area with nested guards
Multi-pane dashboards
Related resources
Last updated
Was this helpful?