{"id":25676396,"url":"https://github.com/react-earth/react-happy-global-state","last_synced_at":"2026-01-30T03:40:25.827Z","repository":{"id":174699657,"uuid":"652650987","full_name":"react-earth/react-happy-global-state","owner":"react-earth","description":"Easy to manage your global state, just like using the useState hook.","archived":false,"fork":false,"pushed_at":"2024-09-07T06:23:32.000Z","size":891,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-06T08:37:36.345Z","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/react-earth.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,"zenodo":null}},"created_at":"2023-06-12T14:08:37.000Z","updated_at":"2024-09-07T06:23:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"e20d9014-6bac-4b89-bb59-6c9c675a832b","html_url":"https://github.com/react-earth/react-happy-global-state","commit_stats":null,"previous_names":["react-earth/react-happy-global-state"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/react-earth/react-happy-global-state","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-earth%2Freact-happy-global-state","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-earth%2Freact-happy-global-state/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-earth%2Freact-happy-global-state/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-earth%2Freact-happy-global-state/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/react-earth","download_url":"https://codeload.github.com/react-earth/react-happy-global-state/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-earth%2Freact-happy-global-state/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28899225,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T03:36:35.398Z","status":"ssl_error","status_checked_at":"2026-01-30T03:36:34.949Z","response_time":66,"last_error":"SSL_read: 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":[],"created_at":"2025-02-24T14:26:15.362Z","updated_at":"2026-01-30T03:40:25.821Z","avatar_url":"https://github.com/react-earth.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![title](media/repo-header.svg)\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/react-earth/react-happy-global-state\"\u003e\u003cimg alt=\"star\" src=\"https://img.shields.io/github/stars/react-earth/react-happy-global-state.svg?style=social\u0026label=Star\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/react-happy-global-state\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/react-happy-global-state\" alt=\"version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/react-happy-global-state\"\u003e\u003cimg alt=\"minzip\" src=\"https://img.badgesize.io/https:/unpkg.com/react-happy-global-state@latest/dist/index.esm.js?compression=gzip\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/react-happy-global-state\"\u003e\u003cimg alt=\"downloads\" src=\"https://img.shields.io/npm/dm/react-happy-global-state.svg\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/react-earth/react-happy-global-state\"\u003e\u003cimg alt=\"license\" src=\"https://img.shields.io/npm/l/react-happy-global-state\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Quick Features 🥳\n\n- Manage your global state, just like using the useState hook.\n- Built with typescript, provide type protection, code autocompletion, make your app robust.\n- Less than 1kB size.\n\n## How to use 📖\n\n### Install package\n\n```shell\nnpm install react-happy-global-state\n```\n\n### Create your store.ts\n\n```tsx\nimport { createGlobalState } from 'react-happy-global-state';\n\n// define you GlobalState type\ntype GlobalState = {\n  count: number;\n};\n\n// set your default global state\nconst DEFAULT_GLOBAL_STATE: GlobalState = {\n  count: 0,\n};\n\nexport const { GlobalStateProvider, useGlobalState } = createGlobalState({\n  defaultState: DEFAULT_GLOBAL_STATE,\n});\n```\n\n### Use GlobalStateProvider to wrap your App\n\n```tsx\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { App } from './App';\nimport { GlobalStateProvider } from './store';\n\nconst container = document.getElementById('root');\nconst root = createRoot(container!);\n\nroot.render(\n  \u003cReact.StrictMode\u003e\n    {/* use GlobalStateProvider wrap your App  */}\n    \u003cGlobalStateProvider\u003e\n      \u003cApp /\u003e\n    \u003c/GlobalStateProvider\u003e\n  \u003c/React.StrictMode\u003e,\n);\n```\n\n### Use useGlobalState in your Component\n\n```tsx\nimport React from 'react';\nimport { useGlobalState } from './store';\n\nexport const Counter = () =\u003e {\n  // use useGlobalState hook to get/set your global state\n  const [count, setCount] = useGlobalState('count');\n\n  return (\n    \u003cdiv\u003e\n      \u003ch2\u003e{count}\u003c/h2\u003e\n      \u003cbutton onClick={() =\u003e setCount(count + 1)}\u003eIncrement\u003c/button\u003e\n      \u003cbutton onClick={() =\u003e setCount(count - 1)}\u003eDecrement\u003c/button\u003e\n    \u003c/div\u003e\n  );\n};\n```\n\nClick [here](https://codesandbox.io/s/demo-5fvh56?file=/src/App.tsx) to try it by yourself.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freact-earth%2Freact-happy-global-state","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freact-earth%2Freact-happy-global-state","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freact-earth%2Freact-happy-global-state/lists"}