> 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

Add router event listeners and polish the navigation experience.

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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
