{"id":13532566,"url":"https://github.com/wobsoriano/solid-zustand","last_synced_at":"2025-04-09T13:03:36.556Z","repository":{"id":40340552,"uuid":"383510143","full_name":"wobsoriano/solid-zustand","owner":"wobsoriano","description":"🐻 State management in Solid using zustand.","archived":false,"fork":false,"pushed_at":"2024-05-13T19:49:04.000Z","size":432,"stargazers_count":142,"open_issues_count":1,"forks_count":6,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-02T12:12:56.461Z","etag":null,"topics":["solid","state-management","zustand"],"latest_commit_sha":null,"homepage":"https://stackblitz.com/edit/vitejs-vite-tcofpc?file=src/App.tsx","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/wobsoriano.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":"2021-07-06T15:09:27.000Z","updated_at":"2025-03-23T21:19:23.000Z","dependencies_parsed_at":"2024-05-13T20:46:47.070Z","dependency_job_id":"d3791a67-bd4c-4e23-a0a7-5ab4f264ae1a","html_url":"https://github.com/wobsoriano/solid-zustand","commit_stats":{"total_commits":123,"total_committers":1,"mean_commits":123.0,"dds":0.0,"last_synced_commit":"f2f0dbf8e47fde8baf14b5a2bb70755eaeaa5714"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wobsoriano%2Fsolid-zustand","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wobsoriano%2Fsolid-zustand/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wobsoriano%2Fsolid-zustand/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wobsoriano%2Fsolid-zustand/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wobsoriano","download_url":"https://codeload.github.com/wobsoriano/solid-zustand/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045230,"owners_count":21038553,"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":["solid","state-management","zustand"],"created_at":"2024-08-01T07:01:11.911Z","updated_at":"2025-04-09T13:03:36.536Z","avatar_url":"https://github.com/wobsoriano.png","language":"TypeScript","funding_links":[],"categories":["📦 Components \u0026 Libraries"],"sub_categories":["State Management"],"readme":"\u003cp\u003e\n  \u003cimg width=\"100%\" src=\"https://assets.solidjs.com/banner?type=solid-zustand\u0026background=tiles\u0026project=%20\" alt=\"solid-zustand\"\u003e\n\u003c/p\u003e\n\n# solid-zustand\n\n🐻 State management in Solid using [zustand](https://github.com/pmndrs/zustand).\n\n## Install\n\n```sh\npnpm add zustand solid-zustand\n```\n\nDemo: https://stackblitz.com/edit/vitejs-vite-tcofpc\n\n## Usage\n\nFirst create a zustand store\n\n```tsx\nimport { createWithSignal } from 'solid-zustand'\n\ninterface BearState {\n  bears: number\n  increase: () =\u003e void\n}\n\nconst useStore = createWithSignal\u003cBearState\u003e(set =\u003e ({\n  bears: 0,\n  increase: () =\u003e set(state =\u003e ({ bears: state.bears + 1 })),\n}))\n```\n\nThen bind your components, and that's it!\n\n```tsx\nfunction BearCounter() {\n  const bears = useStore(state =\u003e state.bears)\n  return \u003ch1\u003e{bears()} around here ...\u003c/h1\u003e\n}\n\nfunction Controls() {\n  const increase = useStore(state =\u003e state.increase)\n  return \u003cbutton onClick={increase}\u003eone up\u003c/button\u003e\n}\n```\n\nIf you prefer [stores](https://docs.solidjs.com/references/api-reference/stores/using-stores) over [signals](https://www.solidjs.com/docs/latest#createsignal), use `createWithStore` function instead:\n\n```tsx\nimport { createWithStore } from 'solid-zustand'\n\nconst useStore = createWithStore\u003cBearState\u003e(set =\u003e ({\n  bears: {\n    count: 0,\n  },\n  increase: () =\u003e set(state =\u003e ({ bears: state.bears.count + 1 })),\n}))\n\nfunction BearCounter() {\n  const bears = useStore(state =\u003e state.bears)\n  return \u003ch1\u003e{bears.count} around here ...\u003c/h1\u003e\n}\n```\n\n## Recipes\n\n### Fetching everything\n\n```ts\nconst state = useStore()\n```\n\n### Selecting multiple state slices\n\nIt detects changes with strict-equality (old === new) by default, this is efficient for atomic state picks.\n\n```ts\nconst nuts = useStore(state =\u003e state.nuts) // nuts()\nconst honey = useStore(state =\u003e state.honey) // honey()\n```\n\nIf you want to construct a single object with multiple state-picks inside, similar to redux's mapStateToProps, you can tell zustand that you want the object to be diffed shallowly by passing the `shallow` equality function. That function will then be passed to the [`equals`](https://www.solidjs.com/docs/latest/api#options) option of `createSignal` (if using `createWithSignal`):\n\n```ts\nimport shallow from 'zustand/shallow'\n\n// Object pick, either state.nuts or state.honey change\nconst state = useStore(state =\u003e ({ nuts: state.nuts, honey: state.honey }), shallow) // state().nuts, state().honey\n\n// Array pick, either state.nuts or state.honey change\nconst state = useStore(state =\u003e [state.nuts, state.honey], shallow) // state()[0], state()[1]\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwobsoriano%2Fsolid-zustand","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwobsoriano%2Fsolid-zustand","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwobsoriano%2Fsolid-zustand/lists"}