A Svelte store that automatically syncs state with localStorage. Current stable version is 0.6.4. The package provides a simple writable store that persists values under a given key, with built-in JSON serialization. It supports Svelte 3 and 4 (requires ^3.48.0 || >4.0.0). Key differentiator: minimal API (one function), no dependencies besides Svelte, TypeScript types included. Note: This package has been renamed to svelte-persisted-store; new development happens there. For new projects, use svelte-persisted-store instead.
npm install svelte-local-storage-storeNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage of localStorageStore: creating a store, subscribing, setting, updating, and getting the value. Note the store is typed if using TypeScript.
Migrate to svelte-persisted-store. The API is identical; just change the import source.
Change to named import: import { localStorageStore } from 'svelte-local-storage-store'.Convert non-serializable values to a plain object mirror before storing, or implement custom serialization.
Guard store usage with browser check (import { browser } from '$app/environment') or use the store only on the client side.Consider using svelte-persisted-store which supports Svelte 4 and may be updated for Svelte 5.
Use named import: import { localStorageStore } from 'svelte-local-storage-store'Check if running in browser: if (typeof localStorage !== 'undefined') { ... }Install the package: npm install svelte-local-storage-store. If using TypeScript, ensure tsconfig includes 'node_modules/@types' or the package's types.
Catch the error or use a try-catch when accessing the store, or provide fallback in-memory store.