svelte-router
Purpose: Svelte Router SPA is a routing library designed specifically for Svelte applications, focusing on Single Page Applications (SPA). It organizes routes in a centralized location and provides features for modern web applications with minimal configuration.
Target Audience: Developers building Svelte-based SPAs who need a robust routing solution with features like nested routes, layouts, localization, and route guards.
Key Features:
- Centralized route definitions
- Support for global, per-page, or nested layouts
- Nested routes and named parameters
- Localization support for multilingual routes
- Route guards for protected routes
- Route prefixing
- Google Analytics integration (optional)
- Standard
<a>
element support with enhanced<Navigate>
component
Svelte Support: Primarily designed for Svelte, with no additional framework support mentioned.
Notable Capabilities:
- Dynamic route matching with named parameters (e.g.,
show/:id
) - Programmatic navigation via
navigateTo
- Route localization with language-specific paths
- 404 handling with custom components
- Current route information propagation via
currentRoute
object
- Dynamic route matching with named parameters (e.g.,
Localization: Supports multilingual routes through language-specific path definitions and automatic route conversion based on active language.
Component API:
<Router>
: Main component that manages route matching and rendering<Route>
: Used within layouts to render nested content<Navigate>
: Enhanced link component with active route detection- Helper functions like
navigateTo
,routeIsActive
, andlocalisedRoute
Example Use Case: The library is used in [Demanda](https://github.com/jorgegorka/demanda fa-solid fa-up-right-from-square), an open-source e-commerce platform with Svelte frontend.
Development Status: Feature complete with only bug fixes being addressed (no new features planned).
Credits: Developed by Jorge Alvarez with contributions from multiple developers.