⚡ Kosha – A Minimal, Modern State Manager for React
Looking for a fast, ergonomic, and lightweight state management solution tailored for modern React?
Meet Kosha – a ~450 byte, production-ready global state manager built with React 18+ in mind. It gives you the performance of useSyncExternalStore
and the elegance of Immer – all in one tiny package.
🚀 Why Kosha?
Kosha was built to simplify state management for real-world apps — small enough to fit in your head, but powerful enough to scale.
✨ Highlights
- Ultra-lightweight (~450 bytes minzipped)
-
Zero re-renders by default – powered by
useSyncExternalStore
- Modular slice architecture – supports Zustand-style slices
- Built-in middleware support
- TypeScript-first DX – store creation, selection, and updates are fully typed
- Test-ready – includes testing utilities to reset stores between test cases
📦 Installation
npm i kosha
# or
yarn add kosha
# or
pnpm add kosha
`
🧩 Slice Composition (Modular Store Setup)
`ts
type Store = CounterSlice & ThemeSlice;
const createCounterSlice: SliceCreator = set => ({
count: 0,
setCount: count => set({ count }),
});
const createThemeSlice: SliceCreator = set => ({
theme: 'light',
setTheme: theme => set({ theme }),
});
const useStore = create((...a) => ({
...createCounterSlice(...a),
...createThemeSlice(...a),
}));
`
🧪 Testing Made Simple
`ts
import { create } from 'kosha/utils/test';
const useTestStore = create(set => ({
count: 0,
increment: () => set(state => ({ count: state.count + 1 })),
}));
// Automatically resets between tests
`
🌐 See it Live
❤️ Built with love by Mayank Chaudhari
Give Kosha a try — and say goodbye to bloated state libraries ✌️
Let me know what you build with it! 🚀
Top comments (0)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.