Welcome to v5.0

Version 5.0 is a complete rewrite for Svelte 5, bringing modern runes-based reactivity, powerful new features, and significant improvements to the developer experience.

This is the first stable release of svelte-spa-router for Svelte 5, providing enterprise-grade routing with comprehensive features for building complex single-page applications.

🎯 Built for Svelte 5 with Runes

The entire router has been rewritten using Svelte 5's new runes system ($state, $derived, $effect), providing better performance and more predictable reactivity.

Modern runes-based API
 

🔄 Automatic Referrer Tracking

The router now automatically tracks where users came from, including route parameters, query strings, route names, and scroll positions.

Referrer tracking with scroll restoration
 

Learn more about referrer tracking →

🐛 Category-Based Debug Logging

A comprehensive logging system with 12 hierarchical categories, color-coded output, and timestamps makes debugging routing issues easier than ever.

Fine-grained logging control
 

Categories include: ROUTER, ROUTER:NAVIGATION, ROUTER:SCROLL, ROUTER:GUARDS, ROUTER:PERMISSIONS, and 7 more for comprehensive debugging.

Learn more about debug logging →

⚠️ Global Error Handling

Catch and recover from unhandled errors automatically with configurable recovery strategies, restart loop prevention, and beautiful error UI.

Automatic error recovery
 

Learn more about error handling →

🌳 Hierarchical Route Inheritance

Child routes can now automatically inherit breadcrumbs, permissions, conditions, and authorization callbacks from parent routes, reducing code duplication.

Route inheritance system
 

Learn more about hierarchical routes →

📁 Tree/Nested Route Structure

Define deeply nested routes using a tree structure instead of flat definitions, perfect for complex applications with many levels of nesting.

Nested route definitions
 

Learn more about tree structure →

🔐 Enhanced Permission System

The unauthorized handling system has been redesigned to respect routing modes and support component-based display without changing URLs.

Improved unauthorized handling
 

Learn more about permissions →

✨ Additional Improvements

goBack() Helper

Simplified navigation to previous route with automatic scroll position restoration:

 

Strict Parameter Replacement

Missing route parameters are now replaced with a configurable placeholder (default: "N-A") instead of being silently removed, making it easier to spot missing data:

 

Consistent API Naming

All Router event props now use camelCase for consistency with JavaScript conventions:

  • onRouteLoading (was onrouteLoading)
  • onRouteLoaded (was onrouteLoaded)
  • onConditionsFailed (was onconditionsFailed)

Improved TypeScript Support

Enhanced type definitions with better generics support for typed route params, query strings, and navigation context.

⚡ Performance

  • Lighter weight: Runes-based implementation is more efficient than stores
  • Zero overhead logging: Debug logging has negligible impact when disabled
  • Better tree-shaking: Improved bundle size in production builds
  • Faster route matching: Optimized pattern matching with regexparam

🛠️ Developer Experience

Better Error Messages

Clear, actionable error messages help you identify and fix issues quickly:

Route "unknownRoute" not found in registry. Registered routes: [ 'home', 'about', 'user' ]

Comprehensive Documentation

  • Complete API reference with all functions documented
  • Detailed feature guides with real-world examples
  • Migration guide from v4 to v5
  • Troubleshooting sections for common issues

Live Examples

Two full example applications demonstrate all features:

⚠️ Breaking Changes

While v5.0 includes breaking changes, the core routing API remains familiar. Most changes are straightforward find-and-replace operations:

  • $locationlocation()
  • $paramsrouteParams()
  • onrouteLoadedonRouteLoaded
  • setDebugLoggingEnabled()enableLogging()

See the Migration Guide for complete upgrade instructions.

🚀 Get Started

Ready to try v5.0? Install it now:

 

Then check out the Getting Started guide to build your first route!

💬 Feedback Welcome

Found a bug? Have a feature request? We'd love to hear from you: