svelte-micro
Purpose: Svelte Micro is a lightweight and reactive client-side router designed specifically for Svelte 4 applications. It provides a simple yet powerful way to handle routing within Svelte apps.
Key Features:
- Reactive routing with stores for path, query, and hash (
path
,query
,hash
stores) - Nested route support via the
Route
component - Programmatic navigation using the
router
object (go
,push
,replace
) - Customizable routing options (
mode
,basePath
) via theoptions
store <Link>
component andlinkHandle
action for SPA-style navigation- Utility functions like
getPathSegments
for path manipulation
- Reactive routing with stores for path, query, and hash (
Target Audience: Svelte developers looking for a minimal, reactive routing solution without heavy dependencies.
Framework Support: Exclusively designed for Svelte (version 4).
Notable Components:
<Route>
: Defines route boundaries and nested routes<Link>
: Handles internal navigation without page reloadslinkHandle
: Action to prevent default link behavior
Advanced Capabilities:
- Route guarding (conditional rendering)
- Redirects
- Scroll behavior control
- Query parameter handling
Example Use Case:
<Route>
<Route path="/">
<h1>Home</h1>
<Link href="/about">About</Link>
</Route>
<Route path="/about">
<h1>About Page</h1>
</Route>
</Route>
For more details, see the GitHub repository .
svelterouterlightreactive
Featured Stories
No featured articles here. Navigate to an article, then pick the Feature on menu button