svelte-persisted-store
- A Svelte store that persists data to
localStorage
orsessionStorage
, with cross-tab synchronization capabilities. - Purpose: Provides persistent state management for Svelte applications by automatically saving store values to browser storage.
- Key Features:
- Automatic persistence to
localStorage
(default) orsessionStorage
- Tab synchronization (enabled by default)
- Custom serialization support (defaults to
JSON
, can use libraries likedevalue
) - Error handling hooks (
onWriteError
,onParseError
) - Value transformation hooks (
beforeRead
,beforeWrite
) - Standard Svelte store interface with additional
reset()
method
- Automatic persistence to
- Target Audience: Svelte developers needing persistent client-side state that survives page refreshes and syncs across tabs.
- Usage Patterns:
- Works like regular Svelte stores (
subscribe
,update
,set
) - Supports Svelte's auto-subscription syntax (
$store
) - Can be read with
get()
from 'svelte/store'
- Works like regular Svelte stores (
- Storage Options:
local
(default) - persists across sessionssession
- persists only for current session
- License: MIT fa-solid fa-up-right-from-square
sveltelocalstoragepubsubsessionstorage
Author
Featured Stories
No featured articles here. Navigate to an article, then pick the Feature on menu button