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
Copy file name to clipboardExpand all lines: README.md
+21-11Lines changed: 21 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,11 +54,11 @@ The simplest and most effective way to use this library is by importing the meth
54
54
Your username is {$username}
55
55
```
56
56
57
-
the function returns a store so make sure to use it with the `$` prepended to handle auto-subscriprion. In case there's not a query parameter with the chosen name it will simply be null.
57
+
the function returns a store so make sure to use it with the `$` prepended to handle auto-subscription. In case there's not a query parameter with the chosen name it will simply be null.
58
58
59
59
### Writing to the store (single parameter)
60
60
61
-
Reading query parameters is cool but you know what is even cooler? Writing query parameters! With this library you can treat your store just like normal state in svelte. To update the state and conseguentely the url you can just do this
61
+
Reading query parameters is cool but you know what is even cooler? Writing query parameters! With this library you can treat your store just like normal state in svelte. To update the state and consequently the url you can just do this
62
62
63
63
```svelte
64
64
<script lang="ts">
@@ -107,7 +107,7 @@ The count is {$count}
107
107
<input bind:value={$count} type="number" />
108
108
```
109
109
110
-
this time $count would be of type number and the deconding function it's what's used to update the url when you write to the store.
110
+
this time $count would be of type number and the decoding function it's what's used to update the url when you write to the store.
111
111
112
112
### Default values
113
113
@@ -322,7 +322,7 @@ There are six helpers all exported as functions on the object ssp. To each one o
322
322
323
323
#### object
324
324
325
-
To map from a query parameter to an object. An url like this `/?obj={"isComplex":%20true,%20"nested":%20{"field":%20"value"}}` will be mapped to
325
+
To map from a query parameter to an object. A url like this `/?obj={"isComplex":%20true,%20"nested":%20{"field":%20"value"}}` will be mapped to
To map from a query parameter to an array. An url like this `/?arr=[1,2,3,4]` will be mapped to
335
+
To map from a query parameter to an array. A url like this `/?arr=[1,2,3,4]` will be mapped to
336
336
337
337
```typescript
338
338
$store.arr[0]; //1
@@ -343,27 +343,27 @@ $store.arr[3]; //4
343
343
344
344
#### number
345
345
346
-
To map from a query parameter to a number. An url like this `/?num=1` will be mapped to
346
+
To map from a query parameter to a number. A url like this `/?num=1` will be mapped to
347
347
348
348
```typescript
349
349
$store.num; //1
350
350
```
351
351
352
352
#### boolean
353
353
354
-
To map from a query parameter to a boolean. An url like this `/?bool=true` will be mapped to
354
+
To map from a query parameter to a boolean. A url like this `/?bool=true` will be mapped to
355
355
356
356
```typescript
357
357
$store.bool; //true
358
358
```
359
359
360
-
as we've seen an url like this `/?bool=false` will be mapped to
360
+
as we've seen a url like this `/?bool=false` will be mapped to
361
361
362
362
```typescript
363
363
$store.bool; //false
364
364
```
365
365
366
-
just like an url like this `/`
366
+
just like a url like this `/`
367
367
368
368
#### string
369
369
@@ -373,12 +373,22 @@ This is exported mainly for readability since all query parameters are already s
373
373
374
374
To map any JSON serializable state to his lz-string representation. This is a common way to store state in query parameters that will prevent the link to directly show the state.
375
375
376
-
An url like this `/?state=N4IgbghgNgrgpiAXCAsgTwAQGMD2OoYCO8ATpgA4QkQC2cALnCSAL5A` will map to
376
+
A url like this `/?state=N4IgbghgNgrgpiAXCAsgTwAQGMD2OoYCO8ATpgA4QkQC2cALnCSAL5A` will map to
377
377
378
378
```typescript
379
379
$store.state.value; //My cool query parameter
380
380
```
381
381
382
+
#### base64
383
+
384
+
To store more complicated strings, such as those containing unicode characters, newlines, or other special characters, you can use the base64 helper. The helper follows the "Base64 URL safe" pattern described in the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Glossary/Base64).
385
+
386
+
A url like this `/?state=YSDEgCDwkICAIOaWhyDwn6aE` will map to
387
+
388
+
```typescript
389
+
$store.state.value; //a Ā 𐀀 文 🦄
390
+
```
391
+
382
392
## Store options
383
393
384
394
Both functions accept a configuration object that contains the following properties:
@@ -468,7 +478,7 @@ To set the configuration object you can pass it as a third parameter in case of
468
478
</script>
469
479
```
470
480
471
-
## Vite dependecies error
481
+
## Vite dependencies error
472
482
473
483
If you ran into issues with vite you need to update your `vite.config.ts` or `vite.config.js` file to include the plugin exported from `sveltekit-search-params/plugin`. It's as simple as
0 commit comments