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)