{"id":14962597,"url":"https://github.com/macfja/svelte-persistent-store","last_synced_at":"2025-05-15T14:06:57.828Z","repository":{"id":42527953,"uuid":"342928069","full_name":"MacFJA/svelte-persistent-store","owner":"MacFJA","description":"A Svelte store that keep its value through pages and reloads","archived":false,"fork":false,"pushed_at":"2024-10-25T20:35:06.000Z","size":710,"stargazers_count":250,"open_issues_count":11,"forks_count":16,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-15T14:06:42.847Z","etag":null,"topics":["cookie","indexeddb","localstorage","sessionstorage","storages","store","svelte","sveltejs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/MacFJA.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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":"2021-02-27T18:25:54.000Z","updated_at":"2025-05-03T03:39:22.000Z","dependencies_parsed_at":"2024-01-06T11:53:44.094Z","dependency_job_id":"938e8a57-87b7-4d87-ac02-061bde9291d7","html_url":"https://github.com/MacFJA/svelte-persistent-store","commit_stats":{"total_commits":49,"total_committers":6,"mean_commits":8.166666666666666,"dds":0.1428571428571429,"last_synced_commit":"806c24394f1d23e30482bf85b578ac7b0d37b8ca"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacFJA%2Fsvelte-persistent-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacFJA%2Fsvelte-persistent-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacFJA%2Fsvelte-persistent-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacFJA%2Fsvelte-persistent-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MacFJA","download_url":"https://codeload.github.com/MacFJA/svelte-persistent-store/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254355335,"owners_count":22057354,"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":["cookie","indexeddb","localstorage","sessionstorage","storages","store","svelte","sveltejs"],"created_at":"2024-09-24T13:30:07.355Z","updated_at":"2025-05-15T14:06:52.818Z","avatar_url":"https://github.com/MacFJA.png","language":"TypeScript","readme":"# Svelte Persistent store\n\nA Svelte store that keep its value through pages and reloads\n\n![Github CI](https://github.com/macfja/svelte-persistent-store/workflows/Quality%20tools/badge.svg)\n![GitHub Repo stars](https://img.shields.io/github/stars/macfja/svelte-persistent-store?style=social)\n![NPM bundle size](https://img.shields.io/bundlephobia/minzip/@macfja/svelte-persistent-store)\n![Download per week](https://img.shields.io/npm/dw/@macfja/svelte-persistent-store)\n![License](https://img.shields.io/npm/l/@macfja/svelte-persistent-store)\n![NPM version](https://img.shields.io/npm/v/@macfja/svelte-persistent-store)\n![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/@macfja/svelte-persistent-store)\n\n## Installation\n\n```\nnpm install @macfja/svelte-persistent-store\n```\n\n## Usage\n\n```javascript\nimport { persist, createLocalStorage } from \"@macfja/svelte-persistent-store\"\nimport { writable } from \"svelte/store\"\n\nlet name = persist(writable(\"John\"), createLocalStorage(), \"name\")\n\n$name = \"Jeanne Doe\"\n\n// if you reload the page the value of $name is 'Jeanne Doe'\n```\n\n```javascript\nimport { persistBrowserSession } from \"@macfja/svelte-persistent-store\"\nimport { writable } from \"svelte/store\"\n\nlet title = persistBrowserSession(writable(\"Unsaved\"), \"document-name\")\n\n$title = \"My Document\"\n\n// if you reload the page the value of $title is 'My Document'\n```\n\n```javascript\nimport { writable } from \"@macfja/svelte-persistent-store\"\n\n// Create a wriatble store, persisted in browser LocalStorage, with the key `name`\nlet name = writable(\"name\", \"John\")\n\n$name = \"Jeanne Doe\"\n\n// if you reload the page the value of $name is 'Jeanne Doe'\n```\n\n## Features\n\n-   Multiple storages (Allow to have the best suited usage depending on your use case)\n-   Work with any Svelte store\n-   Work with classes, objects, primitive\n\n## Storages\n\nThere are 6 storages built-in:\n\n-   `createLocalStorage()`, that use `window.localStorage` to save values\n-   `createSessionStorage()`, that use `window.sessionStorage` to save values\n-   `createCookieStorage()`, that use `document.cookie` to save values\n-   `createIndexedDBStorage()`, that use `window.indexedDB` to save value\n-   `createChromeStorage()`, that use `chrome.storage` to save values\n-   `createEncryptedStorage()`, that wrap a storage to encrypt data (and key)\n\nYou can add more storages, you just need to implement the interface `StorageInterface`\n\n## Documentation\n\nDocumentation and examples can be generated with `npm run doc`, next open `docs/index.html` with your favorite web browser.\n\n(Hint: If you don't want to generate the docs, a part of the example and documentation are available [here](.docs/README.md))\n\n### Types\n\nThe persist function will return a new Store with type `PersistentStore\u003cT\u003e`.\n\nThe full signature of `persist` is:\n\n```typescript\ndeclare function persist\u003cT\u003e(store: Writable\u003cT\u003e, storage: StorageInterface\u003cT\u003e, key: string): PersistentStore\u003cT\u003e\n```\n\nThe persist function add a `delete` function on the store.\n\nMore information about types can be found in the generated `types/index.d.ts` (`npm run prebuild`) or in the generated documentation (`npm run doc`).\n\n## Backwards Compatibility Break\n\n### `1.3.0` to `2.0.0`\n\nData persisted in version `1.3.0` may not be deserializable with version `2.*`.\n\nIf you have persisted store that contains Javascript class with version `1.3.0` of `@macfja/svelte-persistent-store` you will not be able to get the data by default.\nThis is due to a change of data serialization. More information [here](.docs/How-To/06-Change-Serialization.md)\n\n## Contributing\n\nContributions are welcome. Please open up an issue or create PR if you would like to help out.\n\nRead more in the [Contributing file](CONTRIBUTING.md)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmacfja%2Fsvelte-persistent-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmacfja%2Fsvelte-persistent-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmacfja%2Fsvelte-persistent-store/lists"}