šļø Type-Safe Web Storage API Wrapper for Svelte
Installations
npm install @jill64/svelte-storage
Developer Guide
Typescript
Yes
Module System
ESM
Node Version
20.18.1
NPM Version
10.8.2
Score
55.8
Supply Chain
83.5
Quality
86.6
Maintenance
50
Vulnerability
98.6
License
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (58.72%)
Svelte (29.13%)
JavaScript (7.19%)
HTML (4.96%)
Love this project? Help keep it running ā sponsor us today! š
Developer
Download Statistics
Total Downloads
1,420,637
Last Day
559
Last Week
5,720
Last Month
77,791
Last Year
1,167,528
GitHub Statistics
MIT License
1 Stars
1,370 Commits
2 Watchers
8 Branches
1 Contributors
Updated on Feb 03, 2025
Bundle Size
718.00 B
Minified
413.00 B
Minified + Gzipped
Package Meta Information
Latest Version
2.0.0
Package Id
@jill64/svelte-storage@2.0.0
Unpacked Size
7.32 kB
Size
3.01 kB
File Count
9
NPM Version
10.8.2
Node Version
20.18.1
Published on
Dec 29, 2024
Total Downloads
Cumulative downloads
Total Downloads
1,420,637
Last Day
-3.5%
559
Compared to previous day
Last Week
-71.5%
5,720
Compared to previous week
Last Month
-25.9%
77,791
Compared to previous month
Last Year
361.3%
1,167,528
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Peer Dependencies
2
@jill64/svelte-storage
šļø Type-Safe Web Storage API Wrapper for Svelte
Installation
1npm i @jill64/svelte-storage
Simple Example
Passing the localStorage
key to the storage
function will retrieve the svelte-store of that value.
1<script> 2 import { storage } from '@jill64/svelte-storage' 3 4 /** @type {Writable<string>} */ 5 const str = storage('localStorage-key', { 6 // Use sessionStorage instead of localStorage 7 // sessionStorage: boolean (default: false) 8 }) 9 10 // Get value 11 $: consol.log($str) 12 13 // Set value 14 $str = 'value' 15 // or 16 str.set('value') 17</script>
Typed Storage
By passing a conversion function as the second argument, you can get the value converted to any type.
1<script> 2 import { storage } from '@jill64/svelte-storage' 3 import { number } from '@jill64/svelte-storage/serde' 4 5 /** @type {Writable<number>} */ 6 const store = storage( 7 'localStorage-key', 8 { 9 stringify: (value) => value.toString(), 10 parse: (str) => parseInt(str) 11 } 12 // { 13 // Storage Option 14 // } 15 ) 16</script>
Prepared Converters
You can also use the prepared converters in @jill64/svelte-storage/serde
.
1<script> 2 import { storage } from '@jill64/svelte-storage' 3 import { number } from '@jill64/svelte-storage/serde' 4 5 /** @type {Writable<number>} */ 6 const num = storage( 7 'localStorage-key', 8 number 9 // { 10 // Storage Option 11 // } 12 ) 13</script>
License

No vulnerabilities found.

No security vulnerabilities found.