Overview
Version 5.0 is a major release built for Svelte 5, featuring a complete rewrite using runes instead of stores. This guide covers all breaking changes and provides step-by-step upgrade instructions.
Breaking Changes Summary
| Change | v4.x (Old) | v5.0 (New) |
|---|---|---|
| State management | Svelte stores | Svelte 5 runes ($state, $derived) |
| State access | $location, $params | location(), routeParams() |
| Parameter name | params | routeParams |
| Router events | onrouteLoading | onRouteLoading (camelCase) |
| Logger API | setDebugLoggingEnabled() | enableLogging(), setCategoryLevel() |
| Unauthorized handling | Hash-based navigation + onUnauthorized | Component-based + configurePermissions() |
| Import paths | /stores export path exists | No /stores path - removed |
Step-by-Step Migration
1. Update Dependencies
2. Update State Access Patterns
Replace store subscriptions with function calls:
3. Update Route Component Props
Route components receive params via $props():
4. Update Router Event Handlers
Event handler props are now camelCase:
5. Update Logger API
The debug logging API has been completely redesigned:
6. Update Permission System
Unauthorized handling is now component-based:
7. Remove /stores Import Path
The /stores export path no longer exists:
Common Migration Issues
Issue: "Cannot read properties of undefined (reading 'before')"
Cause: Using sync component import with createProtectedRoute()
Solution: This is fixed in v5.0.0. Both patterns now work:
Issue: "enableCategory is not a function"
Cause: Using old logger API name
Solution: Use setCategoryLevel() instead:
Issue: "$params is not defined"
Cause: Trying to use store syntax with v5
Solution: Use function call with $derived:
Issue: "Missing './stores' specifier"
Cause: Trying to import from removed /stores path
Solution: Import from main module:
Migration Checklist
Before You Start
- ☐ Back up your project
- ☐ Review breaking changes list
- ☐ Ensure tests exist for critical routes
Code Changes
- ☐ Update Svelte to v5.0+
- ☐ Update @keenmate/svelte-spa-router to v5.0
- ☐ Replace all
$location,$params,$querystringwith function calls - ☐ Rename
paramstorouteParams - ☐ Update Router event props to camelCase
- ☐ Replace
export let paramswithlet { routeParams } = $props() - ☐ Update logger API calls
- ☐ Update permission system configuration
- ☐ Remove /stores import paths
Testing
- ☐ Test all routes navigate correctly
- ☐ Test route parameters work
- ☐ Test protected routes and permissions
- ☐ Test navigation guards and conditions
- ☐ Test referrer tracking (if used)
- ☐ Test error handling (if configured)
Cleanup
- ☐ Remove old debug logging code
- ☐ Update documentation
- ☐ Review and remove unused imports
New Features to Explore
After migrating, consider adopting these new v5 features:
- Category-based Logging: Fine-grained debug logging with 12 categories
- Referrer Tracking: Automatic previous route tracking with scroll position restoration
- goBack() Helper: Navigate to referrer with automatic scroll restoration
- Hierarchical Routes: Automatic breadcrumb and permission inheritance
- Global Error Handler: Comprehensive error handling with recovery strategies
- Enhanced Permission System: Component-based unauthorized handling
- Tree Route Structure:
createHierarchy()for nested route definitions
See the What's New in v5 page for detailed information about all new features.
Getting Help
If you encounter issues during migration:
- Check the API Reference for updated function signatures
- Review example code in the documentation
- Enable debug logging to troubleshoot routing issues
- Open an issue on GitHub