{"id":14987593,"url":"https://github.com/zustandjs/zustand-xs","last_synced_at":"2025-04-02T22:07:28.648Z","repository":{"id":251309704,"uuid":"837029562","full_name":"zustandjs/zustand-xs","owner":"zustandjs","description":"XState/store compabile middleware for Zustand","archived":false,"fork":false,"pushed_at":"2025-02-25T00:33:03.000Z","size":86,"stargazers_count":63,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T08:46:39.318Z","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/zustandjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2024-08-02T04:20:21.000Z","updated_at":"2025-03-03T20:18:52.000Z","dependencies_parsed_at":"2024-08-02T05:44:22.718Z","dependency_job_id":null,"html_url":"https://github.com/zustandjs/zustand-xs","commit_stats":null,"previous_names":["zustandjs/zustand-xs"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zustandjs%2Fzustand-xs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zustandjs%2Fzustand-xs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zustandjs%2Fzustand-xs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zustandjs%2Fzustand-xs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zustandjs","download_url":"https://codeload.github.com/zustandjs/zustand-xs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246899658,"owners_count":20851898,"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":[],"created_at":"2024-09-24T14:14:58.986Z","updated_at":"2025-04-02T22:07:28.626Z","avatar_url":"https://github.com/zustandjs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zustand-xs\n\n[![CI](https://img.shields.io/github/actions/workflow/status/zustandjs/zustand-xs/ci.yml?branch=main)](https://github.com/zustandjs/zustand-xs/actions?query=workflow%3ACI)\n[![npm](https://img.shields.io/npm/v/zustand-xs)](https://www.npmjs.com/package/zustand-xs)\n[![size](https://img.shields.io/bundlephobia/minzip/zustand-xs)](https://bundlephobia.com/result?p=zustand-xs)\n[![discord](https://img.shields.io/discord/627656437971288081)](https://discord.gg/MrQdmzd)\n\nXState/store compabile middleware for Zustand\n\n## Motivation\n\nJust for fun.\nInspired by https://tkdodo.eu/blog/introducing-x-state-store.\n\n## Install\n\n```bash\nnpm install zustand zustand-xs\n```\n\n## Usage\n\n```tsx\nimport { create } from 'zustand';\nimport { xs } from 'zustand-xs';\n\nconst useCountStore = create(\n  xs(\n    {\n      count: 0,\n      text: 'hello',\n    },\n    {\n      inc: {\n        count: (context) =\u003e context.count + 1,\n      },\n      updateText: (_context, event: { text: string }) =\u003e ({\n        text: event.text,\n      }),\n      reset: { count: 0, text: 'hello' },\n    },\n  ),\n);\n\nconst Counter = () =\u003e {\n  const count = useCountStore((state) =\u003e state.count);\n  const text = useCountStore((state) =\u003e state.text);\n  const inc = () =\u003e useCountStore.send({ type: 'inc' });\n  const updateText = (text: string) =\u003e\n    useCountStore.send({ type: 'updateText', text });\n  const reset = () =\u003e useCountStore.send({ type: 'reset' });\n  return (\n    \u003c\u003e\n      \u003cp\u003e\n        Count: {count}\n        \u003cbutton type=\"button\" onClick={inc}\u003e\n          +1\n        \u003c/button\u003e\n      \u003c/p\u003e\n      \u003cp\u003e\n        \u003cinput value={text} onChange={(e) =\u003e updateText(e.target.value)} /\u003e\n      \u003c/p\u003e\n      \u003cp\u003e\n        \u003cbutton type=\"button\" onClick={reset}\u003e\n          Reset\n        \u003c/button\u003e\n      \u003c/p\u003e\n    \u003c/\u003e\n  );\n};\n```\n\n## Examples\n\nThe [examples](examples) folder contains working examples.\nYou can run one of them with\n\n```bash\nPORT=8080 pnpm run examples:01_counter\n```\n\nand open \u003chttp://localhost:8080\u003e in your web browser.\n\nYou can also try them directly:\n[01](https://stackblitz.com/github/zustandjs/zustand-xs/tree/main/examples/01_counter)\n\n## Tweets\n\n- https://x.com/dai_shi/status/1819232740749070438\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzustandjs%2Fzustand-xs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzustandjs%2Fzustand-xs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzustandjs%2Fzustand-xs/lists"}