{"id":15064406,"url":"https://github.com/devunt/sveltekit-ssr-store","last_synced_at":"2025-04-10T12:15:11.362Z","repository":{"id":154052543,"uuid":"629089971","full_name":"devunt/sveltekit-ssr-store","owner":"devunt","description":"A drop-in replacement for Svelte stores, safe to use with SvelteKit SSR.","archived":false,"fork":false,"pushed_at":"2023-06-27T02:47:01.000Z","size":71,"stargazers_count":44,"open_issues_count":2,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T02:02:53.401Z","etag":null,"topics":["svelte","svelte-kit","svelte-store","svelte-stores","sveltekit"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@svelte-kits/store","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/devunt.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}},"created_at":"2023-04-17T15:41:58.000Z","updated_at":"2024-11-04T22:25:00.000Z","dependencies_parsed_at":"2023-06-28T14:32:23.465Z","dependency_job_id":null,"html_url":"https://github.com/devunt/sveltekit-ssr-store","commit_stats":null,"previous_names":["devunt/svelte-stores","svelte-kits/store"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devunt%2Fsveltekit-ssr-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devunt%2Fsveltekit-ssr-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devunt%2Fsveltekit-ssr-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devunt%2Fsveltekit-ssr-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devunt","download_url":"https://codeload.github.com/devunt/sveltekit-ssr-store/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248217083,"owners_count":21066633,"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":["svelte","svelte-kit","svelte-store","svelte-stores","sveltekit"],"created_at":"2024-09-25T00:17:25.417Z","updated_at":"2025-04-10T12:15:11.336Z","avatar_url":"https://github.com/devunt.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @svelte-kits/store\n\nA drop-in replacement for Svelte stores, safe to use with [SvelteKit](https://kit.svelte.dev/) SSR.\nThis library exposes the same API as `svelte/store`, but with modified stores that are safe to use with SvelteKit SSR.\n\nThis library has `svelte` and `@sveltejs/kit` as peer dependencies, so it cannot be used without SvelteKit.\n\n\n## Installation\n\nInstall `@svelte-kits/store` with your favorite package manager.\n\n```bash\n$ npm install -D @svelte-kits/store\n$ yarn add -D @svelte-kits/store\n$ pnpm add -D @svelte-kits/store\n```\n\n\n## Usage/Examples\n\nSince `@svelte-kits/store` is a drop-in replacement, just replace `svelte/store` with `@svelte-kits/store` in your code.\nAll of the original svelte stores are available, and the API is identical.\n\nSome of the stores are modified to be safe to use with SvelteKit SSR.\n`@svelte-kits/store` re-exports the rest of unmodified stores and types from `svelte/store` for convenience.\n\n```diff\n- import { get, writable, derived, type Updater } from \"svelte/store\";\n+ import { get, writable, derived, type Updater } from \"@svelte-kits/store\";\n  \n  export const count = writable(0); // Safe to use with SSR!\n```\n\n\n## Why?\nShared stores are a great way to share state between components, but they can be tricky to use with SvelteKit SSR.\nSince shared stores are global, if they are used in a long-running environment like a server, they can leak state between requests. \n\nSvelteKit explicitly documents that storing global variable [should be avoided](https://kit.svelte.dev/docs/state-management#avoid-shared-state-on-the-server), and there is active discussion ongoing about [the dangerous behavior of stores with SSR](https://github.com/sveltejs/kit/discussions/4339).\n\nThis library provides a drop-in replacement for Svelte stores that are safe to use with SvelteKit SSR, by providing a new set of stores that are isolated to each request.\nWith `@svelte-kits/store`, you can safely use shared stores in your SvelteKit app in the same manner as before, without keeping them in context manually or worrying about leaking state between requests.\n\nCurrently only the `writable` store is modified since it is the only store that is not safe to use with SSR. Other stores does not save any state within them, so they are fundamentally safe to use with SSR (unless you kept a state in a global variable somewhere else in your code. please don't to that).\n\n\n## Implementation detail\n\nSince it is relatively simple, you can have a look at [code](https://github.com/svelte-kits/store/blob/main/src/lib/writable.ts).\n\n\n## Authors\n\n- [@devunt](https://github.com/devunt)\n\n\n## Contributing\n\nContributions are always welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevunt%2Fsveltekit-ssr-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevunt%2Fsveltekit-ssr-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevunt%2Fsveltekit-ssr-store/lists"}