{"id":49470,"library":"svelte-local-storage-store","title":"svelte-local-storage-store (renamed to svelte-persisted-store)","description":"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.","status":"renamed","version":"0.6.4","language":"javascript","source_language":"en","source_url":"https://github.com/joshnuss/svelte-local-storage-store","tags":["javascript","svelte","typescript"],"install":[{"cmd":"npm install svelte-local-storage-store","lang":"bash","label":"npm"},{"cmd":"yarn add svelte-local-storage-store","lang":"bash","label":"yarn"},{"cmd":"pnpm add svelte-local-storage-store","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: Svelte stores and reactivity are required for the store to function.","package":"svelte","optional":false}],"imports":[{"note":"This is a named export, not a default export. Common mistake: using default import.","wrong":"import localStorageStore from 'svelte-local-storage-store'","symbol":"localStorageStore","correct":"import { localStorageStore } from 'svelte-local-storage-store'"},{"note":"Since rename, svelte-persisted-store is the correct package. The old package still works but is deprecated.","wrong":"import { localStorageStore } from 'svelte-local-storage-store'","symbol":"localStorageStore","correct":"import { localStorageStore } from 'svelte-persisted-store'"},{"note":"CJS require must destructure. However, the package is ESM-first and may not work with require in newer Node versions.","wrong":"const localStorageStore = require('svelte-local-storage-store')","symbol":"localStorageStore","correct":"const { localStorageStore } = require('svelte-local-storage-store')"}],"quickstart":{"code":"import { localStorageStore } from 'svelte-local-storage-store';\nimport { get } from 'svelte/store';\n\n// Create a persisted store with default value\nconst count = localStorageStore('count', 0);\n\n// Subscribe\nconst unsub = count.subscribe(value => {\n  console.log('count:', value);\n});\n\n// Update\ncount.set(5); // saves to localStorage\ncount.update(n => n + 1);\n\n// Get current value (outside Svelte component)\nconsole.log(get(count)); // 6\n\n// Clean up\nunsub();","lang":"typescript","description":"Shows basic usage of localStorageStore: creating a store, subscribing, setting, updating, and getting the value. Note the store is typed if using TypeScript."},"warnings":[{"fix":"Migrate to svelte-persisted-store. The API is identical; just change the import source.","message":"Package has been renamed to svelte-persisted-store. This package will no longer receive updates.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Change to named import: import { localStorageStore } from 'svelte-local-storage-store'.","message":"Version 0.5.0 changed the export from a default export to a named export. Any code using 'import store from ...' will break.","severity":"breaking","affected_versions":">=0.5.0 <1.0.0"},{"fix":"Convert non-serializable values to a plain object mirror before storing, or implement custom serialization.","message":"The store uses JSON.stringify/parse for serialization. Storing non-serializable values (e.g., Date, Map, Set) will cause data loss.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Guard store usage with browser check (import { browser } from '$app/environment') or use the store only on the client side.","message":"localStorage is not available in server-side rendering (SSR) contexts like SvelteKit load functions. Attempting to use the store there will throw a ReferenceError.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider using svelte-persisted-store which supports Svelte 4 and may be updated for Svelte 5.","message":"The package has Svelte 3 peer dep version range ^3.48.0 || >4.0.0. It may not work with Svelte 5 or later.","severity":"deprecated","affected_versions":">=0.6.0"}],"env_vars":null,"search_vec":"'0.6.4':25 '3':49 '3.48.0':53 '4':51 '4.0.0':54 'api':58 'automat':16 'besid':63 'built':42 'built-in':41 'current':21 'depend':62 'develop':80 'differenti':56 'function':60 'given':38 'happen':81 'includ':67 'instead':91 'javascript':92 'json':44 'key':39,55 'local':3 'localstorag':20 'minim':57 'new':79,84 'note':68 'one':59 'packag':27,70 'persist':10,34,77,89 'project':85 'provid':28 'renam':6,73 'requir':52 'serial':45 'simpl':30 'stabl':22 'state':18 'storag':4 'store':5,11,14,32,78,90 'support':47 'svelt':2,9,13,48,64,76,88,93 'svelte-local-storage-stor':1 'svelte-persisted-stor':8,75,87 'sync':17 'type':66 'typescript':65,94 'use':86 'valu':35 'version':23 'writabl':31","created_at":"2026-06-07T17:01:56.130619+00:00","updated_at":"2026-06-07T17:01:56.130619+00:00","problems":[{"fix":"Use named import: import { localStorageStore } from 'svelte-local-storage-store'","cause":"Using default import when the package exports a named export.","error":"TypeError: localStorageStore is not a function"},{"fix":"Check if running in browser: if (typeof localStorage !== 'undefined') { ... }","cause":"Using the store in a server-side environment like SvelteKit load function or Node.js.","error":"ReferenceError: localStorage is not defined"},{"fix":"Install the package: npm install svelte-local-storage-store. If using TypeScript, ensure tsconfig includes 'node_modules/@types' or the package's types.","cause":"Package not installed or import path incorrect.","error":"Cannot find module 'svelte-local-storage-store' or its corresponding type declarations."},{"fix":"Catch the error or use a try-catch when accessing the store, or provide fallback in-memory store.","cause":"User's browser settings have disabled localStorage (e.g., private mode in some browsers, or localStorage quota exceeded).","error":"Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': Storage is disabled."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/joshnuss/svelte-local-storage-store#readme","github":"https://github.com/joshnuss/svelte-local-storage-store","docs":null,"changelog":null,"pypi":null,"npm":"svelte-local-storage-store","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}