You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### **A Modern, Lightweight, and High-Performance State Management Library for React**
12
12
13
-
**Kosha** is a production-ready, minimalistic global state management solution for modern React applications. Weighing in at just **~450 bytes minzipped**, it’s built for developers who care about performance, clean APIs, and full React 18+ compatibility.
13
+
**Kosha** is a production-ready, minimalistic global state management solution for modern React applications. At just **\~450 bytes minzipped**, it's optimized for performance-critical applications, full React 18+ support, and clean developer ergonomics.
14
+
15
+
Live demo: [https://kosha-six.vercel.app](https://kosha-six.vercel.app)
Explorethe [`examples/`](https://github.com/react18-tools/kosha/tree/main/examples) directory for working codebases, including component and selector examples.
const user = await fetch("/api/user").then(res => res.json());
179
+
set({ user });
180
+
},
181
+
}));
166
182
```
167
183
168
-
Zustandmaystilltriggerre-rendershereunlesscarefullyoptimized. See [Zustand’sofficialdocs](https://github.com/pmndrs/zustand/blob/main/docs/guides/prevent-rerenders-with-use-shallow.md) for details.
184
+
### 3.DoesKoshasupportmiddlewarelikeZustand?
169
185
170
-
---
186
+
Yes. Middlewaresupportisbuilt-in. Aworkingpersistmiddlewareisincluded. Youcaneasilybuildyourownorextendwithlogging, devtools, etc.
171
187
172
-
## 📁 Examples
188
+
### 4.CanIuseitwith`Set`, `Map`, or`Date`objects?
173
189
174
-
Youcanfindreal-worldusageexamplesinsidethe [`examples/`](https://github.com/react18-tools/kosha/tree/main/examples) directory of this repository.
No — inKosha, you’recomparingoutputsofthesameselectorfunction across renders. Since the order of keys in JavaScript objects is preserved in deterministic function outputs, JSON.stringify remains stable and reliable in this context.
175
195
176
196
---
177
197
178
-
## ❓ FAQ
198
+
## 🚧 Known Limitations
179
199
180
-
### 1.IsKoshaproduction-ready?
200
+
Kosha is intentionally minimal by design — built to offer just what most React apps need, without bloat. That comes with a few tradeoffs:
201
+
202
+
### 🧠 Selector Comparison via `JSON.stringify`
203
+
204
+
Kosha uses `JSON.stringify` internally to compare selector outputs for change detection. This works extremely well for the majority of cases — even with moderately large or deeply nested selectors.
> ✅ It’s perfectly fine to have a large store or global state.
213
+
> ⚠️ What matters is the **output of your selector**. If you’re selecting a large slice like `state => ({ a:state.a, ..., z:state.z })`, it’s more efficient to either:
214
+
>
215
+
> - Access the store directly without a selector (`useKosha()`), or
216
+
> - Extract only the minimal fields you actually need.
Kosha includes full support for custom middleware and already ships with a working [persist middleware](https://github.com/mayank1513/kosha/blob/main/lib/src/middleware/persist.ts). However:
191
221
192
-
### 4.DoesKoshasupportReactServerComponents?
222
+
- Built-in plugins like `devtools` are not yet included.
223
+
- A community-driven plugin ecosystem is still in its early stages.
> Kosha always compares results of the **same selector function**, so the key order is preserved unless your selector behaves non-deterministically (e.g., relies on `Object.keys()` or mutation).
255
+
> As long as your selector returns a consistent structure, `JSON.stringify` comparison will be reliable.
207
256
208
257
---
209
258
210
259
## 📜 License
211
260
212
261
Kosha is licensed under the **MPL-2.0** license.
213
262
214
-
<imgsrc="https://raw.githubusercontent.com/mayank1513/mayank1513/main/popper.png"style="height: 20px"/> Explore [ourcourses](https://mayank-chaudhari.vercel.app/courses) or [support development](https://github.com/sponsors/mayank1513).
263
+
<img src="https://raw.githubusercontent.com/mayank1513/mayank1513/main/popper.png" style="height: 20px"/> Explore [my courses](https://mayank-chaudhari.vercel.app/courses) or [support development](https://github.com/sponsors/mayank1513).
0 commit comments