-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
Describe the problem
This FAQ lists Svelte v4 and older routers, so it would be nice if it were updated with Svelte v5-native routers, and clean up the abandoned projects.
Describe the proposed solution
Remove the abandoned projects and list new ones.
I made one myself, which makes me very proud. It has features no other router in the world possesses. For example, it supports path and hash routing simultaneously. There's a features table here, if you're curious.
My proposal additions, if I may be so bold, are listed in the table below. It describes what I know about them. The LOC (lines of code) column is calculated using ALDanial's cloc utility.
Svelte v5 Native Routers in Existence
Project | LOC | Tests? | Summary |
---|---|---|---|
@wjfe/n-savant | 1256 | Yes. Over 850. | Reactive-based router. Uses a SvelteURL instance as base for all calclulations, making everything reactive-driven. No events needed. Just $derived() and $effect() . Can define routes in code or in component markup. Complete freedom of content: Use the children snippets. Components: Router , Route , Link , Fallback , LinkContext , RouterTrace |
@dvcol/svelte-simple-router | 2688 | Yes | Seems to require route definitions via code, then given to the RouterView component. Doesn't seem to derive calculations from a single reactive source, but router information does seem to be using Svelte reactivity. Routes define the components they mount. Components: RouterView , RouteView , RouterContext |
@mateothegreat/svelte5-router | 1806 | Yes | Also requires definition of routes in code, which are then given to the Router component. There is no Link component, and you are meant to add the route action to HTML anchor elements. Must define the components routes render in code. Components: Router |
@hvniel/svelte-router | 8935 | Yes | Direct port of React Router. I don't want to even browse this codebase. If someone wants to summarize, then by all means do. |
Note
Except for my project (the first, see LOC in the online docs), I used the command line perl ..\cloc.pl .\src\lib --exclude-ext="test.ts"
. Maybe this is not the best for a particular project. My bad. I don't know them all. Treat the LOC as an approximation.
These are the native router implementations I know. If someone knows more, please add to the list.
Seemingly abandoned routers mentioned in the Svelte FAQ page: page.js
, navaid
, svelte-routing
, svelte-navigator
, svelte-spa-router
.
Importance
nice to have