Troubleshooting

Common router issues, debugging techniques, and solutions for troubleshooting Aurelia router problems.

This guide covers common router issues, debugging techniques, and solutions to help you quickly resolve routing problems in your Aurelia applications.

Common Issues and Solutions

1. Routes Not Matching

Problem: Configured routes are not being matched or components not loading.

Symptoms:

  • Blank viewport

  • No component loaded

  • "Route not found" errors

Solutions:

Check Route Configuration

// ❌ Common mistake - Missing quotes around path
@route({
  routes: [
    { path: home, component: Home } // Missing quotes
  ]
})

// ✅ Correct
@route({
  routes: [
    { path: 'home', component: Home }
  ]
})

Verify Route Registration

Debug Route Matching

2. Component Not Loading

Problem: Route matches but component doesn't appear.

Debugging Steps:

1. Check Viewport Configuration

2. Verify Component Registration

3. Check Component Lifecycle

3. Navigation Not Working

Problem: Clicking links or calling router.load() doesn't navigate.

Common Causes and Fixes:

2. Href vs Load Attribute Conflicts

3. Router Configuration Issues

4. router.load('../1') throws UnknownRouteError

Symptom: await this.router.load('../1') rejects with UnknownRouteError: AUR3401 ... did you forget to add '..1' to the routes list of 'root'?, yet <a load="../1"> works.

Why it happens: router.load() always evaluates instructions in the root routing context unless you pass a context option, so ../ cannot be resolved relative to the current child router.

Fix: Resolve IRouteContext (or pass the component instance created by the router) and provide it in the navigation options.

If you need to navigate relative to different ancestors (for example inside a reusable widget), compute the target context at runtime (e.g., const parent = this.routeContext.parent ?? this.routeContext;) before calling router.load.

4. Parameters Not Available

Problem: Route parameters are undefined or not accessible.

Debugging:

1. Check Parameter Definition

2. Access Parameters Correctly

5. Query Parameters Issues

Problem: Query parameters not working or not accessible.

Solutions:

1. Setting Query Parameters

2. Reading Query Parameters

6. Hash Routing Issues

Problem: Hash routing not working correctly.

Configuration Check:

7. Push State Routing Issues

Problem: Push state routing not working, especially on refresh.

Solutions:

1. Server Configuration

2. Base Tag Configuration

Debugging Techniques

1. Enable Router Logging

2. Router Event Monitoring

3. Route State Inspection

4. Component Lifecycle Debugging

Performance Issues

1. Slow Route Loading

Causes and Solutions:

1. Large Component Bundles

2. Heavy Lifecycle Operations

2. Memory Leaks

Common Causes:

1. Event Subscriptions Not Cleaned Up

2. Large Route Trees

Development vs Production Issues

1. Works in Development but Not Production

Common Causes:

1. Build Configuration

2. Base Path Configuration

2. Different Behavior Between Hash and Push State

Error Messages and Solutions

Common Error Messages

  1. "No route found for path"

    • Check route configuration

    • Verify fallback routes

    • Enable route logging

  2. "Component not found"

    • Verify component registration

    • Check import statements

    • Confirm component exports

  3. "Navigation cancelled"

    • Check lifecycle hooks

    • Verify canLoad/canUnload return values

    • Look for thrown exceptions

  4. "Viewport not found"

    • Ensure <au-viewport> is present

    • Check viewport names match

    • Verify viewport hierarchy

Quick Debugging Checklist

✅ Router Setup

✅ Route Configuration

✅ Components

This troubleshooting guide provides practical solutions for the most common router issues, helping developers quickly identify and resolve routing problems.

Last updated

Was this helpful?