{"id":24801220,"url":"https://github.com/alimertcakar/zustand-sync","last_synced_at":"2026-04-27T21:32:22.520Z","repository":{"id":272966263,"uuid":"918323529","full_name":"alimertcakar/zustand-sync","owner":"alimertcakar","description":"Simple middleware to sync zustand store between multiple tabs","archived":false,"fork":false,"pushed_at":"2025-01-20T10:52:59.000Z","size":28,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-26T10:35:11.970Z","etag":null,"topics":["zustand","zustand-middleware","zustand-persist","zustand-state-management","zustandmiddleware"],"latest_commit_sha":null,"homepage":"https://zustand-sync.netlify.app/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alimertcakar.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-01-17T17:36:57.000Z","updated_at":"2025-10-23T22:35:27.000Z","dependencies_parsed_at":"2025-01-17T18:43:56.096Z","dependency_job_id":"cfb0945e-2989-4a45-84a5-8885a57127c1","html_url":"https://github.com/alimertcakar/zustand-sync","commit_stats":null,"previous_names":["alimertcakar/zustand-sync"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alimertcakar/zustand-sync","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alimertcakar%2Fzustand-sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alimertcakar%2Fzustand-sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alimertcakar%2Fzustand-sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alimertcakar%2Fzustand-sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alimertcakar","download_url":"https://codeload.github.com/alimertcakar/zustand-sync/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alimertcakar%2Fzustand-sync/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32356598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"ssl_error","status_checked_at":"2026-04-27T20:07:00.910Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["zustand","zustand-middleware","zustand-persist","zustand-state-management","zustandmiddleware"],"created_at":"2025-01-30T04:19:45.565Z","updated_at":"2026-04-27T21:32:22.503Z","avatar_url":"https://github.com/alimertcakar.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Zustand Sync Middleware\n\nThis middleware for Zustand allows you to synchronize store data between different browser tabs. When the state changes in one tab, the updated state will be reflected in all other open tabs. You can use this with zustand/persist with no issues.\nSyncing is only supported with localStorage (duh).\n\nDemo: https://zustand-sync.netlify.app/  \nCodesandbox: https://codesandbox.io/p/sandbox/zustand-sync-zk5dvg\n\n## Installation\n\nTo install the middleware, you can use pnpm, npm or yarn:\n\n```sh\npnpm add zustand-sync-middleware\n# or\nnpm install zustand-sync-middleware\n# or\nyarn add zustand-sync-middleware\n```\n\n## Usage\n\nTo use the middleware, import it and apply it to your Zustand store:\n\n```typescript\nimport create from \"zustand\";\nimport sync from \"zustand-sync-middleware\";\n\nconst useStore = create(\n  sync((set) =\u003e ({\n    // ...your slices\n  }))\n);\n```\n\n## Usage with zustand/persist\n\nYou have to put `sync` middleware before `persist` middleware. Share the key you used to persist your store at. (This is used to watch `localStorage[persistanceKey]`)\nAdditionally, you can add `enabled: false` to skip the middleware.\n\n```typescript\nconst storageUnit = localStorage;\nconst persistanceKey = \"persisted-store\";\n\nconst persistOptions = {\n  name: persistanceKey,\n  storage: createJSONStorage(() =\u003e storageUnit),\n  partialize: (state) =\u003e ({\n    count: state.count,\n    name: state.name,\n  }),\n};\n\nconst syncOptions = {\n  name: persistanceKey,\n  enabled: storageUnit === localStorage,\n};\n\nconst useStore = create(\n  persist(\n    sync(\n      (set) =\u003e ({\n        // ...your slices\n      }),\n      syncOptions\n    ),\n    persistOptions\n  )\n);\n```\n\nWarning: Don't call `sync(persist(...)) instead of persist(sync())` if you want to sync only the data you filtered in `partialize` in `persistOptions`.\n\n## Thank you! ❤️\n\n⭐ If you liked the library, can you star this repo? ⭐\nhttps://github.com/alimertcakar/zustand-sync\n\nAlso, the source code is super simple and pr's are welcome!\n\n## License\n\nThis project is licensed under the MIT License. Meaning: do whatever you want with it as long as you don't sue me.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falimertcakar%2Fzustand-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falimertcakar%2Fzustand-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falimertcakar%2Fzustand-sync/lists"}