11# @wjfe/n-savant
22
3- > Small router for Svelte v5 SPA's specialized for micro-frontends .
3+ > The client-side router for Svelte v5 SPA's that invented multi hash routing .
44
55## Features
66
7- This router's code is small, revolving the ** 900** lines of code, including typing.
7+ > [ !NOTE]
8+ > #### Small and Unique!
9+ >
10+ > + Less than ** 900** lines of code, including TypeScript typing.
11+ > + Always-on path and hash routing. Simultaneous and independent routing modes.
12+ > + The router that invented multi hash routing.
813
914+ ** Reactivity-based** : All data is reactive, reducing the need for events and imperative programming.
1015+ ** Always-on path and hash routing** : Add routers that use the URL's path name or the URL's hash value in the same
1116application. Both routing modes are possible simultaneously.
12- + ** Multi-hash routing** : Unique to this router and not found in any other router library, you can create named paths
13- in the hash value of the URL and create router hierarchies that use a specific named path.
17+ + ** Multi-hash routing** : This is the first router in the world to do this: You can create named paths in the hash
18+ value of the URL and create router hierarchies that use a specific named path.
1419
1520### ` <Router> ` Component
1621
@@ -165,15 +170,17 @@ or matches most of the time, so navigation links are available the mayority/all
165170
166171Components (` Router ` , ` Route ` , ` Link ` , ` Fallback ` and ` RouterTrace ` ) with the same value of the ` hash ` property belong
167172to the same "universe". Components with different hash values belong to different universes, and these universes are
168- parallel universes. Components with hash value ` false ` use the URL's path name and will never interere with routers
173+ parallel universes. Components with hash value ` false ` use the URL's path name and will never interfere with routers
169174that use hash routing (hash value ` true ` or a path's name). The main micro-frontend(s) may route using the URL's path
170175name, while specialty MFE's could route using the path in the hash part of the URL.
171176
172177### Multi-Hash Routing
173178
174- Following up from the previous, imagine a scenario where your MFE application would like to show side-by-side two
175- micro-frontends that are router-enabled (meaning they use or need to work with a path). With traditional routing, you
176- could not have this setup because one MFE would take over the path, leaving the other MFE without one.
179+ As of Februrary 2025, no other router in the world can do this.
180+
181+ Imagine a scenario where your MFE application would like to show side-by-side two micro-frontends that are
182+ router-enabled (meaning they use or need to work with a path). With traditional routing, you could not have this setup
183+ because one MFE would take over the path, leaving the other MFE without one.
177184
178185Mutli-hash routing creates named paths in the hash value, giving routers the ability to share the hash value with other
179186routers. A hash value of the form ` #path1=/path/1;path2=/path/2;... ` could power side-by-side MFE's on, say, 4K
@@ -182,14 +189,14 @@ layouts.
182189### EXPERIMENTAL - Replacing the ` single-spa ` Router
183190
184191It is the author's intent to implement micro-frontends with only ` single-spa ` parcels and this router. In other words,
185- abandon the use of ` registerApplication() ` and ` start() ` and just mount parcels.
192+ abandon the use of ` registerApplication() ` and ` start() ` and just mount parcels using this router .
186193
187194[ single-spa] ( https://single-spa.js.org )
188195
189196## Unintrusive Philosophy
190197
191198This mini router library imposes minimal restrictions. Here are some features provided by other much larger codebases
192- (most notably ` dvcol/svelte-simple-router ` ) that are not provided here because Svelte already has the capability.
199+ that are not provided here because Svelte already has the capability.
193200
194201### Transitions
195202
@@ -214,18 +221,19 @@ Nothing prevents you to add transitions to anything.
214221Guard routes however you wish. Maybe with an ` {#if} ` block, or maybe using the route's ` and ` property that allows you
215222to specify a predicate function. There are probably many other ways.
216223
217- ### Exact Property on Routes
224+ ### ` Exact ` Property on Routes
218225
219226Not needed. All matching is exact path matching, and if you want to opt out of the exact route matching, simply add
220- the rest parameter specifier:
227+ the ` rest ` parameter specifier ( ` /* ` ) :
221228
222229``` svelte
223230<Route key="admin" path="/admin/*">
224231 ...
225232</Route>
226233```
227234
228- If you don't care about the value of the parameter, just ignore it.
235+ Now route matching for this route will behave as "starts with". If you don't care about the value of the parameter,
236+ just ignore it.
229237
230238### Lazy-Loading
231239
@@ -344,8 +352,10 @@ import { location } from "@wjfe/n-savant";
344352
345353// Path routing navigation:
346354location .navigate (' /new/path' , { replace: true , state: { custom: ' Hi' }});
355+
347356// Hash routing navigation:
348357location .navigate (' #/new/path' , { replace: true , state: { custom: ' Hi' }});
358+
349359// Multi-hash routing navigation:
350360location .navigate (' /new/path' , ' path1' , { replace: true , state: { custom: ' Hi' }});
351361```
@@ -360,8 +370,10 @@ Just in case you are wondering: The navigation logic is already there in `<Link
360370``` svelte
361371<!-- Path Routing => https://example.com/new/path -->
362372<Link hash="false" href="/new/path">Click Me!</Link>
373+
363374<!-- Hash Routing => https://example.com/#/new/path -->
364375<Link hash="true" href="/new/path">Click Me!</Link>
376+
365377<!-- Multi Hash Routing => https://example.com/#path1=/new/path -->
366378<!-- Will also preserve any other named paths -->
367379<Link hash="path1" href="/new/path">Click Me!</Link>
@@ -382,6 +394,6 @@ on the router layouts, again, **at your own risk**.
382394
383395---
384396
385- [ Full Documentation @ Hashnode Pages ] ( https://wjfe-n-savant.hashnode.pages )
397+ [ Full Documentation @ Hashnode Space ] ( https://wjfe-n-savant.hashnode.space )
386398
387399If you would like to report a bug or request a feature, head to the [ Issues page] ( https://github.com/WJSoftware/wjfe-n-savant/issues ) .
0 commit comments