React developers often juggle between performance, bundle size, and developer ergonomics when choosing a state management library.
Introducing Kosha β a production-ready, ~450 byte global state manager with:
β
Full React 18+ and concurrent rendering support
β
Optimized selectors using useSyncExternalStore
β
Partial updates out-of-the-box
β
Built-in middleware architecture
β
Working persist
middleware
β
No unnecessary re-renders
π§ͺ How it Works
Create a store with a minimal API:
import { create } from "kosha";
const useStore = create(set => ({
count: 0,
increment: () => set(state => ({ count: state.count + 1 })),
}));
`
Use selector-based consumption for optimization:
ts
const count = useStore(state => state.count);
Update state from anywhere, even outside React:
ts
useStore.getState().increment();
βοΈ Kosha vs Zustand
Feature | Kosha | Zustand |
---|---|---|
Size (minzipped) | ~450 bytes | ~0.6β2.5kB |
Optimized Selectors | β Built-in | β οΈ Manual |
Middleware | β (custom) | β Rich plugins |
Devtools | β | β |
π§ Middleware Support Example
Check out the working persist middleware.
π¦ Try It Now
Live demo: kosha-six.vercel.app
Source: github.com/react18-tools/kosha
Let me know what middleware you'd love to see added next!
- Post the long-form blog above with tags:
react
,javascript
,webdev
,opensource
,state-management
- Publish during weekday morning IST/EST (e.g., Tue/Wed ~9β10am IST or EST)
Top comments (0)