{"id":14987498,"url":"https://github.com/nanxiaobei/resso","last_synced_at":"2025-04-12T20:44:05.706Z","repository":{"id":41180331,"uuid":"428859861","full_name":"nanxiaobei/resso","owner":"nanxiaobei","description":"🪢 Simplest React state manager","archived":false,"fork":false,"pushed_at":"2024-04-18T17:15:33.000Z","size":801,"stargazers_count":529,"open_issues_count":0,"forks_count":20,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-03T21:14:42.813Z","etag":null,"topics":["flux","hooks","jotai","react","recoil","reducer","redux","resso","state","state-management","store","typescript","valtio","zustand"],"latest_commit_sha":null,"homepage":"","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/nanxiaobei.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-17T00:41:06.000Z","updated_at":"2025-03-24T01:20:15.000Z","dependencies_parsed_at":"2024-01-11T22:58:17.996Z","dependency_job_id":"d0673d9c-5300-498e-ac3e-c2f0894c3413","html_url":"https://github.com/nanxiaobei/resso","commit_stats":{"total_commits":185,"total_committers":3,"mean_commits":"61.666666666666664","dds":"0.010810810810810811","last_synced_commit":"47f62519fda8eb9228d81ab1c08fb8920494a022"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanxiaobei%2Fresso","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanxiaobei%2Fresso/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanxiaobei%2Fresso/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanxiaobei%2Fresso/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nanxiaobei","download_url":"https://codeload.github.com/nanxiaobei/resso/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631687,"owners_count":21136556,"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":["flux","hooks","jotai","react","recoil","reducer","redux","resso","state","state-management","store","typescript","valtio","zustand"],"created_at":"2024-09-24T14:14:50.021Z","updated_at":"2025-04-12T20:44:05.683Z","avatar_url":"https://github.com/nanxiaobei.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\nLink in bio to **widgets**,\nyour online **home screen**. ➫ [🔗 kee.so](https://kee.so/)\n\n\u003c/div\u003e\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\u003ch1\u003e🪢 resso\u003c/h1\u003e\n\nThe simplest React state manager. _Auto on-demand re-render ⚡️_\n\n**R**eactive **E**legant **S**hared **S**tore **O**bject\n\n(Support React 18, React Native, SSR, Mini Apps)\n\n[![npm](https://img.shields.io/npm/v/resso?style=flat-square)](https://www.npmjs.com/package/resso)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/nanxiaobei/resso/test.yml?branch=main\u0026style=flat-square)](https://github.com/nanxiaobei/resso/actions/workflows/test.yml)\n[![npm bundle size](https://img.shields.io/bundlephobia/minzip/resso?style=flat-square)](https://bundlephobia.com/result?p=resso)\n[![npm type definitions](https://img.shields.io/npm/types/typescript?style=flat-square)](https://github.com/nanxiaobei/resso/blob/main/src/index.ts)\n[![GitHub](https://img.shields.io/github/license/nanxiaobei/resso?style=flat-square)](https://github.com/nanxiaobei/resso/blob/main/LICENSE)\n\nEnglish · [简体中文](./README.zh-CN.md)\n\n\u003c/div\u003e\n\n## Introduction\n\n[resso, world’s simplest React state manager →](https://nanxiaobei.medium.com/resso-worlds-simplest-react-state-manager-a3b1b0ccaa99)\n\n## Features\n\n- Extremely simple 🪩\n- Extremely smart 🫙\n- Extremely small 🫧\n\n## Install\n\n```sh\npnpm add resso\n# or\nyarn add resso\n# or\nbun add resso\n# or\nnpm i resso\n```\n\n## Usage\n\n```jsx\nimport resso from 'resso';\n\nconst store = resso({\n  count: 0,\n  text: 'hello',\n  inc() {\n    const { count } = store; // must destructure at top (if use in method)\n    store.count = count + 1;\n  },\n});\n\nfunction App() {\n  const { count } = store; // must destructure at top (if use in UI)\n\n  return (\n    \u003c\u003e\n      {count}\n      \u003cbutton onClick={() =\u003e (store.count += 1)}\u003e+\u003c/button\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n\\* destructure at top is calling `useState` (Hooks rules, or may get React error)\n\n[![Edit resso](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/resso-ol8dn?file=/src/App.jsx)\n\n## API\n\n**Single update**\n\n```jsx\nstore.count = 60;\n\nstore('count', (c) =\u003e c + 1);\n```\n\n**Multiple update**\n\n```jsx\nstore({\n  count: 60,\n  text: 'world',\n});\n\nstore((s) =\u003e ({\n  count: s.count + 1,\n  text: s.text === 'hello' ? 'world' : 'hello',\n}));\n```\n\n**Non-state shared vars (Refs)**\n\nActually it's not related to resso, it's just JavaScript. You can do it like this:\n\n```jsx\n// store.js\nexport const refs = {\n  total: 0,\n};\n\n// App.js\nimport store, { refs } from './store';\n\nfunction App() {\n  refs.total = 100;\n  return \u003cdiv /\u003e;\n}\n```\n\n---\n\n**\\* `react\u003c18` batch update**\n\n```jsx\nresso.config({ batch: ReactDOM.unstable_batchedUpdates }); // at app entry\n```\n\n## Re-render on demand\n\n```jsx\n// no text update, no re-render\nfunction Text() {\n  const { text } = store;\n  return \u003cp\u003e{text}\u003c/p\u003e;\n}\n\n// only when count updates, re-render\nfunction Count() {\n  const { count } = store;\n  return \u003cp\u003e{count}\u003c/p\u003e;\n}\n\n// no state in UI, no re-render\nfunction Control() {\n  return (\n    \u003c\u003e\n      \u003cbutton onClick={store.inc}\u003e+\u003c/button\u003e\n      \u003cbutton onClick={() =\u003e (store.count -= 1)}\u003e-\u003c/button\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n## License\n\n[MIT License](https://github.com/nanxiaobei/resso/blob/main/LICENSE) (c) [nanxiaobei](https://lee.so/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnanxiaobei%2Fresso","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnanxiaobei%2Fresso","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnanxiaobei%2Fresso/lists"}