svelte-navigator-lite 1.0.2 → 1.1.1
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 +14 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -110,30 +110,16 @@ Add `optional: true` to make a trailing segment optional. Optional segments must
|
|
|
110
110
|
|
|
111
111
|
## Search Params
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
Declared in `searchParams`. The route only matches if all listed params are present in the URL. Their values are captured into `router.params`.
|
|
113
|
+
Declared in `searchParams`. Listed params are captured into `router.params` if present in the URL, and silently ignored if absent. They never affect whether a route matches.
|
|
116
114
|
|
|
117
115
|
```ts
|
|
118
116
|
'password-reset': {
|
|
119
117
|
rootPath: 'password-reset',
|
|
120
118
|
segments: [],
|
|
121
|
-
searchParams: ['token'],
|
|
122
|
-
}
|
|
123
|
-
// router.params.token === 'abc'
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### Optional search params
|
|
127
|
-
|
|
128
|
-
Declared in `optionalSearchParams`. Captured into `router.params` if present, silently ignored if absent. Do not affect whether the route matches.
|
|
129
|
-
|
|
130
|
-
```ts
|
|
131
|
-
'signup': {
|
|
132
|
-
rootPath: 'signup',
|
|
133
|
-
segments: [],
|
|
134
|
-
optionalSearchParams: ['redirect'], // matches /signup and /signup?redirect=/dashboard
|
|
119
|
+
searchParams: ['token'],
|
|
135
120
|
}
|
|
136
|
-
// router.params.
|
|
121
|
+
// /password-reset?token=abc → router.params.token === 'abc'
|
|
122
|
+
// /password-reset → router.params === {}
|
|
137
123
|
```
|
|
138
124
|
|
|
139
125
|
---
|
|
@@ -249,6 +235,16 @@ Returns `true` if `router.route` is any of the provided route names.
|
|
|
249
235
|
class:active={router.matches(['dashboard', 'settings'])}
|
|
250
236
|
```
|
|
251
237
|
|
|
238
|
+
### `router.registerRoute(name, route)`
|
|
239
|
+
|
|
240
|
+
Register a new route.
|
|
241
|
+
```ts
|
|
242
|
+
registerRoute('settings', {
|
|
243
|
+
rootPath: 'settings',
|
|
244
|
+
segments: [],
|
|
245
|
+
routeGuards: [guards.authenticated],
|
|
246
|
+
})
|
|
247
|
+
|
|
252
248
|
### `page`
|
|
253
249
|
|
|
254
250
|
A readable Svelte store that emits `{ url: URL }` and updates on every navigation. Useful when you need the raw URL.
|