Example Applications
The example app ships in both routing modes β same source, mode picked by the VITE_ROUTING_MODE environment variable. Two live deploys are kept current
with main:
π History Mode
Clean URLs via the History API. Requires server fallback to index.html in production (nginx, Apache, etc.).
make dev β localhost:5050π Hash Mode
Hash-based #/path routing. No server config needed β works on
static hosting, file://, anywhere.
make dev-hash β localhost:5051Demos by Category
Every demo below links to the history-mode deploy. For hash mode, swap https://history⦠for https://hash.svelte-spa-router.keenmate.dev/# and prepend # to the path.
/querystring-demoβ built-in helpers + custom formatter (OData / Microsoft Graph)/filters-demoβ flat and structured filter modes/route-data-demoβ typed params, optional and wildcard segments/tabs/:idβ tab UI with querystring state preserving breadcrumbs/user/:first/:lastβ multi-segment params/book/*β wildcard catch-all routes
/define-routes-demoβ type-safedefineRoutes()withnav/pathshelpers/route-context-demoβrouteContext()for per-route static data/metadata-demoβ page titles + breadcrumbs viarouteBreadcrumbs()/loading-demoβshouldDisplayLoadingOnRouteLoad+hideLoading()/multi-zone-demoβ independent zones (sidebar / main / panel) sharing a router/admin-treeβ tree-structured routes viacreateHierarchy()
/error-handling-demoβGlobalErrorHandler+ recovery strategies/not-found-demoβonNotFoundtracking + catch-all behavior
/authorization-demoβ asyncauthorizationCallbackfor per-resource checks/adminβ permission-protected route (toggle user in the header to test)/settingsβ protected route requiringsettings:manage
Tip: the example header has a Toggle π€ button to switch between users with different permission sets.
Running Examples Locally
One example app, two modes. Mode is picked via the VITE_ROUTING_MODE env var
(cross-env handles cross-platform).
Using Make (Recommended)
# History mode (port 5050)
make dev
# Hash mode (port 5051)
make dev-hashUsing npm
cd example
npm install
# History mode
npm run dev:history
# Hash mode
npm run dev:hashSource Code
The example app source lives in the main router repository under example/.
Both routing modes share the same source β the mode is selected at build time.
E2E test fixtures
Minimal Playwright fixtures kept separate from the user-facing demos. Useful when reading the spec suite.
View fixtures on GitHubQuick Tips
Explore Features
Open every demo at least once β many have multiple sections covering edge cases
View Source
The example/ files are the canonical reference β feature pages are written from them
Experiment
Run locally with make dev and edit example/src/routes/ to test changes
Read Docs
Each Features page on the left has a deep-link to its matching demo