{"id":14987600,"url":"https://github.com/react18-tools/zustand-sync-tabs","last_synced_at":"2025-08-14T08:46:45.964Z","repository":{"id":190953533,"uuid":"683654552","full_name":"react18-tools/zustand-sync-tabs","owner":"react18-tools","description":"Zustand middleware to easily sync Zustand state between tabs / windows / iframes (Same Origin)","archived":false,"fork":false,"pushed_at":"2025-01-24T07:10:34.000Z","size":53,"stargazers_count":32,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-09T16:57:22.868Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/react18-tools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["mayank1513"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":["https://pages.razorpay.com/mayank1513"]}},"created_at":"2023-08-27T09:21:54.000Z","updated_at":"2025-08-07T18:00:22.000Z","dependencies_parsed_at":"2023-08-27T10:42:33.842Z","dependency_job_id":"aabb9284-6a36-4a32-9f9f-2c2d2b96ad49","html_url":"https://github.com/react18-tools/zustand-sync-tabs","commit_stats":{"total_commits":23,"total_committers":1,"mean_commits":23.0,"dds":0.0,"last_synced_commit":"e9fe2fee8a8316742e8571a9dee7e50bd08d91fe"},"previous_names":["mayank1513/zustand-sync-tabs"],"tags_count":1,"template":false,"template_full_name":"react18-tools/turborepo-template","purl":"pkg:github/react18-tools/zustand-sync-tabs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react18-tools%2Fzustand-sync-tabs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react18-tools%2Fzustand-sync-tabs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react18-tools%2Fzustand-sync-tabs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react18-tools%2Fzustand-sync-tabs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/react18-tools","download_url":"https://codeload.github.com/react18-tools/zustand-sync-tabs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react18-tools%2Fzustand-sync-tabs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270166014,"owners_count":24538440,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-09-24T14:14:59.506Z","updated_at":"2025-08-14T08:46:45.882Z","avatar_url":"https://github.com/react18-tools.png","language":"TypeScript","funding_links":["https://github.com/sponsors/mayank1513","https://pages.razorpay.com/mayank1513"],"categories":[],"sub_categories":[],"readme":"# Zustand Sync Tabs [![Version](https://img.shields.io/npm/v/zustand-sync-tabs.svg?colorB=green)](https://www.npmjs.com/package/zustand-sync-tabs) [![Downloads](https://img.jsdelivr.com/img.shields.io/npm/dt/zustand-sync-tabs.svg)](https://www.npmjs.com/package/zustand-sync-tabs) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/zustand-sync-tabs)\n\n\u003e Zustand middleware to easily sync Zustand state between tabs/windows / iframes (Same Origin)\n\n- ✅ 🐙 ~ 1 kB size cross-tab state sharing middleware for Zustand\n- ✅ Full TypeScript Support\n- ✅ solid reliability in 1 writing and n reading tab scenarios (with changing writing tab)\n- ✅ Fire and forget approach of always using the latest state. Perfect for single-user systems\n- ✅ Sync Zustand state between multiple browsing contexts\n- ✅ Partial state sharing is also supported\n\n\u003e Check out `[persist-and-sync](https://github.com/react18-tools/persist-and-sync)` if you are looking for persisting state locally over reload/refresh or after closing the site.\n\n## Install\n\n```bash\n$ pnpm add zustand-sync-tabs\n```\n**or**\n\n```bash\n$ npm install zustand-sync-tabs\n```\n**or**\n\n```bash\n$ yarn add zustand-sync-tabs\n```\n\n## Usage\n\nAdd the middleware while creating the store and the rest will be taken care.\n\n```ts\nimport { create } from \"zustand\";\nimport { syncTabs } from \"zustand-sync-tabs\";\n\ntype MyStore = {\n\tcount: number;\n\tset: (n: number) =\u003e void;\n};\n\nconst useStore = create\u003cMyStore\u003e(\n\tsyncTabs(\n\t\tset =\u003e ({\n\t\t\tcount: 0,\n\t\t\tset: n =\u003e set({ count: n }),\n\t\t}),\n\t\t{ name: \"my-channel\" },\n\t),\n);\n```\n\n⚡🎉Boom! Just a couple of lines and your state perfectly syncs between tabs/windows and it is also persisted using `localStorage`!\n\n## Advanced - ignore / filter out fields based on regExp\n\nIn several cases you might want to exclude several fields from syncing. To support this scenario, we provide a mechanism to exclude fields based on list of fields or regular expression.\n\n```ts\ntype SyncTabsOptionsType = {\n\tname: string;\n\t/** @deprecated */\n\tregExpToIgnore?: RegExp;\n\tinclude?: (string | RegExp)[];\n\texclude?: (string | RegExp)[];\n};\n```\n\n**Example**\n\n```typescript\nexport const useMyStore = create\u003cMyStoreType\u003e()(\n\tsyncTabs(\n\t\tset =\u003e ({\n\t\t\tcount: 0,\n\t\t\t_count: 0 /** skipped as it is included in exclude array */,\n\t\t\tsetCount: count =\u003e {\n\t\t\t\tset(state =\u003e ({ ...state, count }));\n\t\t\t},\n\t\t\tset_Count: _count =\u003e {\n\t\t\t\tset(state =\u003e ({ ...state, _count }));\n\t\t\t},\n\t\t}),\n\t\t{ name: \"example\", exclude: [\"_count\"] },\n\t),\n);\n```\n\nFor more details about regExp check out - [JS RegExp](https://www.w3schools.com/jsref/jsref_obj_regexp.asp)\n\n### 🤩 Don't forget to star [this repo](https://github.com/mayank1513/turborepo-template)!\n\nWant hands-on course for getting started with Turborepo? Check out [React and Next.js with TypeScript](https://mayank-chaudhari.vercel.app/courses/react-and-next-js-with-typescript) and [The Game of Chess with Next.js, React and TypeScrypt](https://www.udemy.com/course/game-of-chess-with-nextjs-react-and-typescrypt/?referralCode=851A28F10B254A8523FE)\n\n![Alt](https://repobeats.axiom.co/api/embed/6b5fa6a5fbb6affafea042ba0f292ecf9388ef3c.svg \"Repobeats analytics image\")\n\n## License\n\nLicensed as MIT open source.\n\n\u003chr /\u003e\n\n\u003cp align=\"center\" style=\"text-align:center\"\u003ewith 💖 by \u003ca href=\"https://mayank-chaudhari.vercel.app\" target=\"_blank\"\u003eMayank Kumar Chaudhari\u003c/a\u003e\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freact18-tools%2Fzustand-sync-tabs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freact18-tools%2Fzustand-sync-tabs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freact18-tools%2Fzustand-sync-tabs/lists"}