{"id":13735518,"url":"https://github.com/furudean/svelte-persistent-store","last_synced_at":"2025-12-24T19:28:37.321Z","repository":{"id":37970328,"uuid":"494653688","full_name":"furudean/svelte-persistent-store","owner":"furudean","description":"Svelte store that saves and loads data from localStorage or sessionStorage","archived":false,"fork":false,"pushed_at":"2024-04-01T18:46:31.000Z","size":104,"stargazers_count":36,"open_issues_count":6,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-07-23T01:36:33.407Z","etag":null,"topics":["localstorage","sessionstorage","store","svelte","svelte-kit"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/furudean.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-21T01:52:04.000Z","updated_at":"2024-06-24T22:08:33.000Z","dependencies_parsed_at":"2024-01-06T11:56:25.096Z","dependency_job_id":"15e99691-b53a-4875-8ff2-fdeccb50d83d","html_url":"https://github.com/furudean/svelte-persistent-store","commit_stats":{"total_commits":21,"total_committers":2,"mean_commits":10.5,"dds":"0.23809523809523814","last_synced_commit":"6a1761afc58e4d282f6a6e17059341038281eb95"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furudean%2Fsvelte-persistent-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furudean%2Fsvelte-persistent-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furudean%2Fsvelte-persistent-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furudean%2Fsvelte-persistent-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/furudean","download_url":"https://codeload.github.com/furudean/svelte-persistent-store/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":213758654,"owners_count":15634354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["localstorage","sessionstorage","store","svelte","svelte-kit"],"created_at":"2024-08-03T03:01:07.731Z","updated_at":"2025-12-24T19:28:32.302Z","avatar_url":"https://github.com/furudean.png","language":"JavaScript","funding_links":[],"categories":["Browser Storage"],"sub_categories":[],"readme":"\u003cimg src=\"iky.png\"\n  height=\"76\"\n  width=\"62\"\n  align=\"right\"\n  alt=\"A girl\" /\u003e\n\n# [svelte-persistent-store](https://www.npmjs.com/package/@furudean/svelte-persistent-store)\n\nThis is a\n[writable svelte store](https://svelte.dev/docs#run-time-svelte-store-writable)\nthat saves and loads data from `Window.localStorage` or `Window.sessionStorage`.\nWorks with Svelte Kit out of the box.\n\nThe store listens to events from the `Storage` interface and will sync its\ninternal state upon changes. This makes debugging using the developer console\neasy, and it will update across sessions as well.\n\n## Install\n\n```bash\nnpm install @furudean/svelte-persistent-store\n```\n\n## Use\n\n\u003e **Note**: By default only\n\u003e [JSON serializable values](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#description)\n\u003e are handled, but [custom serialization and deserialization functions can be\n\u003e provided](#custom-serialization-functions).\n\n```js\nimport { persistent } from \"@furudean/svelte-persistent-store\"\n\nconst preferences = persistent({\n\tstart_value: {\n\t\tfoo: \"bar\"\n\t},\n\tkey: \"preferences\", // key to save as in Storage\n\tstorage_type: \"localStorage\" // Storage object to use\n})\n```\n\n## Custom serialization functions\n\nSince the `Storage` interface only supports strings, data needs to be converted\nto strings before saving. By default `JSON.stringify` and `JSON.parse` is used.\n\nYou can pass custom serializer and deserializer functions if you require\nspecific behavior when loading or saving data from `Storage`. For example, you\ncan handle `Date`s like this:\n\n```js\nconst persistent_date = persistent({\n\tstart_value: new Date(),\n\tkey: \"my-persistent-date\",\n\tstorage_type: \"localStorage\",\n\tserialize: (date) =\u003e date.toISOString(), // transform before saving\n\tdeserialize: (str) =\u003e new Date(str) // transform after loading\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffurudean%2Fsvelte-persistent-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffurudean%2Fsvelte-persistent-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffurudean%2Fsvelte-persistent-store/lists"}