> For the complete documentation index, see [llms.txt](https://docs.aurelia.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aurelia.io/getting-started/extended-tutorial/step-5-router-events-and-polish.md).

# Step 5: Router events + polish

In this step you will listen to router events and surface navigation state in the UI.

## 1. Listen to router events in the Projects layout

Update `src/pages/projects-page.ts`:

```typescript
import { IDisposable, resolve } from '@aurelia/kernel';
import { IRouterEvents, NavigationEndEvent, route } from '@aurelia/router';
import { ProjectsActivityPage } from './projects-activity-page';
import { ProjectsOverviewPage } from './projects-overview-page';

@route({
  routes: [
    { path: ['', 'overview'], component: ProjectsOverviewPage, title: 'Overview' },
    { path: 'activity', component: ProjectsActivityPage, title: 'Activity' }
  ]
})
export class ProjectsPage {
  lastNavigation = '';

  private readonly events = resolve(IRouterEvents);
  private subscription?: IDisposable;

  bound(): void {
    this.subscription = this.events.subscribe(
      'au:router:navigation-end',
      (event: NavigationEndEvent) => {
        this.lastNavigation = event.instructions.toPath();
      }
    );
  }

  unbinding(): void {
    this.subscription?.dispose();
  }
}
```

Update `src/pages/projects-page.html`:

```html
<import from="../components/app-shell"></import>

<app-shell>
  <h1 au-slot="title">Projects</h1>
  <a au-slot="actions" load="../dashboard">Back to Dashboard</a>

  <nav class="projects-subnav">
    <a load="./">Overview</a>
    <a load="activity">Activity</a>
  </nav>

  <p class="nav-meta" if.bind="lastNavigation">
    Last navigation: ${lastNavigation}
  </p>

  <au-viewport></au-viewport>
</app-shell>
```

## 2. Recap the routing features used

You now have:

* Root routes and child routes
* Active navigation styling via `activeClass`
* Query params synced from the UI
* Programmatic navigation via `IRouter.load`
* Router events via `IRouterEvents`
* Guards (`canLoad` and `canUnload`) for real-world UX

If you want, expand this app by adding child routes under `projects/detail/:id`, or persist notes to storage.

Next step: [Step 6: Route data + auth roles](/getting-started/extended-tutorial/step-6-route-data-and-roles.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.aurelia.io/getting-started/extended-tutorial/step-5-router-events-and-polish.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
