You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an extension package of the [@wjfe/n-savant](https://github.com/WJSoftware/wjfe-n-savant) SPA router, and enables the use of the router in hash mode in Sveltekit projects.
5
+
This is an extension package of the [@svelte-router/core](https://github.com/WJSoftware/svelte-router-core) SPA router, and enables the use of the router in hash mode in Sveltekit projects.
6
6
7
7
## Why Would I Need This?
8
8
9
9
Sveltekit has an excellent file-based router. You should always stick to the built-in router for routing your application. However, as with every other router in existence, you can only do path routing or hash routing, but not both.
10
10
11
-
The `@wjfe/n-savant` router was born to break this barrier: This SPA router can do path and hash routing simultaneously. However, this is a router for SPA's and PWA's that render on the client. It was not designed for SSR scenarios. After all, Sveltekit has routing capabilities included.
11
+
The `@svelte-router/core` router was born to break this barrier: This SPA router can do path and hash routing simultaneously. However, this is a router for SPA's and PWA's that render on the client. It was not designed for SSR scenarios. After all, Sveltekit has routing capabilities included.
12
12
13
-
But what if you wanted to do hash routing on top of Sveltekit's path routing? You can, with this router extension.
13
+
But what if you wanted to do hash routing on top of Sveltekit's path routing? You can today, with this router extension.
14
14
15
15
### Useful Scenarios
16
16
17
17
1. You could show a complex dialog box that is driven by hash routing.
18
18
2. You could mount a micro-frontend that routes with a path in the hash.
19
+
3. You could drive your tabs components with individual named hash paths (this is demonstrated in this repository's demo project).
19
20
20
21
## Quickstart
21
22
22
23
1. Install the package
23
24
```bash
24
-
npm install @wjfe/n-savant-sk# This also installs the @wjfe/n-savant main package
25
+
npm install @svelte-router/kit# This also installs the @svelte-router/core main package
25
26
```
26
27
2. Initialize the library. Ideally, in the root `+layout.svelte` component:
27
28
```svelte
28
29
<script lang="ts">
29
-
import { init } from "@wjfe/n-savant-sk";
30
+
import { init } from "@svelte-router/kit";
30
31
31
32
init(/* options */);
32
33
</script>
33
34
```
34
-
3. Add routers, routes and links forhash navigation as you please.
35
+
3. Add routers, routes and links forhash navigation as you please. Note that these are still imported from the core package, `@svelte-router/core`.
35
36
36
37
>**⚡ Attention!**
37
38
>
38
-
> Early testing has revealed what may or may not be a bug in Svelte or Sveltekit. The situation: Just importing `init` from `@wjfe/n-savant-sk` triggers error `rune_outside_svelte` on the `trace.svelte.js` file in the `@wjfe/n-savant` package. To overcome this, just add `{ ssr: { noExternal: ["@wjfe/n-savant"] }}` to Vite's configuration.
39
+
> Early testing has revealed what may or may not be a bug in Svelte or Sveltekit. The situation: Just importing `init` from `@svelte-router/kit` triggers error `rune_outside_svelte` on the `trace.svelte.js` file in the `@svelte-router/core` package. To overcome this, just add `{ ssr: { noExternal: ["@svelte-router/core"] }}` to Vite's configuration.
39
40
>
40
41
> Hopefully, I'll be able to figure more about this problem in the coming weeks.
41
42
@@ -45,4 +46,4 @@ But what if you wanted to do hash routing on top of Sveltekit's path routing? Y
45
46
46
47
---
47
48
48
-
Generally speaking, you need to understand the `@wjfe/n-savant` router, so have handy its [online documentation](https://wjfe-n-savant.hashnode.space/).
49
+
Generally speaking, you need to understand the `@svelte-router/core` router, so have handy its [online documentation](https://wjfe-n-savant.hashnode.space/).
0 commit comments