svelte-spa-history-router 2.2.0-next.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # svelte-spa-history-router
2
2
 
3
- History base router for Svelte 3 SPA (Single Page Application).
3
+ History base router for [Svelte](https://svelte.dev/) SPA (Single Page Application).
4
+
5
+ > [!TIP]
6
+ > The offcial routing library of Svelte is [SvelteKit](https://svelte.dev/docs/kit/introduction). This library is intented to be used for small project.
7
+
4
8
 
5
9
  ## Features
6
10
 
@@ -58,13 +62,28 @@ For example:
58
62
 
59
63
  ### routeParams
60
64
 
61
- `routeParams` is a store to contain matched value to current route.
65
+ Matched paramaters is passed to component as `params` property.
62
66
 
63
67
  For example:
64
68
 
65
69
  ```html
66
70
  # Article.svelte
67
71
 
72
+ <script lang="ts">
73
+ let { params } = $props();
74
+
75
+ const postId = $derived(parseInt(params.postId));
76
+ </script>
77
+ <div>
78
+ { postId }
79
+ </div>
80
+ ```
81
+
82
+ [Additional] For svelte4, `routeParams` is a store to contain matched value to current route.
83
+
84
+ ```html
85
+ # Article.svelte
86
+
68
87
  <script>
69
88
  import { routeParams } from 'svelte-spa-history-router';
70
89
  </script>
@@ -105,7 +124,7 @@ Example: code spliting (dynamic import)
105
124
  import { Router } from 'svelte-spa-history-router';
106
125
 
107
126
  const routes = [
108
- { path: '/', resolver: _ => import("Home.svelte") },
127
+ { path: '/', resolver: () => import("Home.svelte") },
109
128
  ];
110
129
  </script>
111
130
  <Router {routes}/>
@@ -120,11 +139,11 @@ Example: dynamic routing and pass value to component props.
120
139
  import Article from "./Article.svelte";
121
140
  import NotFound from "./NotFound.svelte";
122
141
 
123
- async function prefetchArticle(route) {
124
- const article = await getArticle(route.params.postId);
142
+ async function prefetchArticle({ params, props }) {
143
+ const article = await getArticle(params.postId);
125
144
  if (article) {
126
145
  // pass value to component props
127
- route.props.article = article;
146
+ props.article = article;
128
147
  return Article;
129
148
  } else {
130
149
  return NotFound;
@@ -184,6 +203,10 @@ store to detect URL changes (including query string or hash)
184
203
 
185
204
  ## ChangeLog
186
205
 
206
+ ### 2.2.0
207
+
208
+ * Support Svelte5
209
+
187
210
  ### 2.2.0-next.1
188
211
 
189
212
  * Fix component type on svelte5 [PR13](https://github.com/ykrods/svelte-spa-history-router/pull/13)