{"id":15275835,"url":"https://github.com/react18-tools/react18-global-store","last_synced_at":"2025-10-08T17:22:19.161Z","repository":{"id":223649903,"uuid":"761116221","full_name":"react18-tools/react18-global-store","owner":"react18-tools","description":"A simple yet elegant, light weight, react18 global store to replace Zustand for better tree shaking. ","archived":false,"fork":false,"pushed_at":"2025-04-17T08:12:47.000Z","size":8368,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-17T13:42:20.965Z","etag":null,"topics":["javascript","mayank1513","nextjs","nextjs14","react","react-library","react18","react18-global-store","tree-shaking","turborepo-template","typescript","zustand"],"latest_commit_sha":null,"homepage":"https://r18gs.vercel.app/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/react18-tools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"contributing.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["react18-tools","mayank1513"],"polar":"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":"2024-02-21T09:15:49.000Z","updated_at":"2025-04-17T08:12:51.000Z","dependencies_parsed_at":"2024-11-07T02:21:43.442Z","dependency_job_id":"12800750-0ac1-42fb-ad7f-0c0d2227d123","html_url":"https://github.com/react18-tools/react18-global-store","commit_stats":null,"previous_names":["react18-tools/r18gs","react18-tools/reacr18-global-store"],"tags_count":29,"template":false,"template_full_name":"react18-tools/turborepo-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react18-tools%2Freact18-global-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react18-tools%2Freact18-global-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react18-tools%2Freact18-global-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react18-tools%2Freact18-global-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/react18-tools","download_url":"https://codeload.github.com/react18-tools/react18-global-store/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250522293,"owners_count":21444510,"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":["javascript","mayank1513","nextjs","nextjs14","react","react-library","react18","react18-global-store","tree-shaking","turborepo-template","typescript","zustand"],"created_at":"2024-09-30T10:07:11.206Z","updated_at":"2025-10-08T17:22:14.101Z","avatar_url":"https://github.com/react18-tools.png","language":"TypeScript","funding_links":["https://github.com/sponsors/react18-tools","https://github.com/sponsors/mayank1513","https://polar.sh/mayank1513","https://pages.razorpay.com/mayank1513"],"categories":[],"sub_categories":[],"readme":"# React18GlobalStore \u003cimg src=\"https://raw.githubusercontent.com/mayank1513/mayank1513/main/popper.png\" style=\"height: 40px\"/\u003e\n\n[![Test](https://github.com/react18-tools/react18-global-store/actions/workflows/test.yml/badge.svg)](https://github.com/react18-tools/react18-global-store/actions/workflows/test.yml)\n[![Maintainability](https://api.codeclimate.com/v1/badges/ec3140063acd8df82481/maintainability)](https://codeclimate.com/github/react18-tools/react18-global-store/maintainability)\n[![Code Coverage](https://codecov.io/gh/react18-tools/react18-global-store/graph/badge.svg)](https://codecov.io/gh/react18-tools/react18-global-store)\n[![Version](https://img.shields.io/npm/v/r18gs.svg?colorB=green)](https://www.npmjs.com/package/r18gs)\n[![Downloads](https://img.jsdelivr.com/img.shields.io/npm/d18m/r18gs.svg)](https://www.npmjs.com/package/r18gs)\n![Bundle Size](https://img.shields.io/bundlephobia/minzip/r18gs)\n[![Gitpod Ready](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/from-referrer/)\n\n\u003e 🌐 **Live Demo with Code**: [https://r18gs.vercel.app/](https://r18gs.vercel.app/)\n\n\u003e **Important Note:**  \n\u003e There are no breaking changes when upgrading from version 2.0.\\* to version 3.\\*. However, we released a major version because version 2.1.0 introduced new APIs. To improve those APIs, we made some breaking changes, which will only affect you if you are using the new features introduced in version 2.1.0.\n\n## Motivation\n\nWhile developing libraries utilizing React 18 features with Zustand, I encountered issues with tree-shaking when importing from specific folders. This caused the creation of multiple Zustand stores, resulting in bugs and unnecessary JavaScript code execution.\n\nTo address this, I created a lightweight, minimalistic store designed for shared states that optimizes tree-shaking and supports component imports from separate files.\n\n## Features\n\n✅ **Full TypeScript Support**  \n✅ **Unlock the Full Power of React18 Server Components**  \n✅ **Compatible with All React18 Build Systems and Frameworks**  \n✅ **Comprehensive Documentation with [Typedoc](https://react18-tools.github.io/react18-global-store)**  \n✅ **Examples for Next.js, Vite, and Remix**  \n✅ **Seamlessly Works with Selectors**\n\n## Simple Global State Across Components\n\nUse the `useRGS` hook just like `useState`, but with a unique key to make the state accessible across components.\n\n```tsx\nconst [state, setState] = useRGS\u003cnumber\u003e(\"counter\", 1);\n```\n\nOr initialize using a function:\n\n```tsx\nconst [state, setState] = useRGS\u003cnumber\u003e(\"counter\", () =\u003e 1);\n```\n\n\u003e 🔗 **Getting Started**: [Guide](./md-docs/1.getting-started.md)\n\n## What's New?\n\n🚀 **Now Supports Selectors for Complex Stores**  \nExplore more at [https://r18gs.vercel.app/](https://r18gs.vercel.app/).\n\n## Using Plugins\n\nExtend the store's functionality with the `create` function, `withPlugins` function, or the `useRGSWithPlugins` hook. Features like persistence to local storage can be easily integrated.\n\n```tsx\n// store.ts\nimport { create } from \"r18gs/dist/with-plugins\";\nimport { persist } from \"r18gs/dist/plugins\"; // Use third-party or custom plugins\n\nexport const useMyPersistentCounterStore = create\u003cnumber\u003e(\"persistent-counter\", 0, [persist()]);\n```\n\nUse it just like `useState` without needing an initial value:\n\n```tsx\nconst [persistedCount, setPersistedCount] = useMyPersistentCounterStore();\n```\n\n\u003e 🔗 **Learn More**: [Leveraging Plugins](./md-docs/2.leveraging-plugins.md)\n\n## Contributing\n\nContributions are welcome! See [contributing.md](/contributing.md).\n\n### 🌟 Don't Forget to Star [this repository](https://github.com/mayank1513/react18-global-store)!\n\n### Hands-On Learning Resources\n\n- [React and Next.js with TypeScript](https://mayank-chaudhari.vercel.app/courses/react-and-next-js-with-typescript)\n- [The Game of Chess with Next.js, React, and TypeScript](https://www.udemy.com/course/game-of-chess-with-nextjs-react-and-typescript/?referralCode=851A28F10B254A8523FE)\n\n![Repo Stats](https://repobeats.axiom.co/api/embed/ec3e74d795ed805a0fce67c0b64c3f08872e7945.svg \"Repobeats Analytics\")\n\n## License\n\nThis library is licensed under the **MPL-2.0** open-source license.\n\n\u003e \u003cimg src=\"https://raw.githubusercontent.com/mayank1513/mayank1513/main/popper.png\" style=\"height: 20px\"/\u003e Support our work by [sponsoring](https://github.com/sponsors/mayank1513) or enrolling in [our courses](https://mayank-chaudhari.vercel.app/courses).\n\n---\n\n\u003cp align=\"center\" style=\"text-align:center\"\u003eMade with 💖 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%2Freact18-global-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freact18-tools%2Freact18-global-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freact18-tools%2Freact18-global-store/lists"}