Tiny useSyncExternalStore-powered context store
npm install @acoolhq/react-tiny-storeTiny, selector-first state for React built on useSyncExternalStore.
Full documentation (guides, API reference, examples) lives at https://acoolhq.github.io/react-tiny-store/.
Head there for detailed quick-starts, slice patterns, and controller recipes.
``bash`
npm i @acoolhq/react-tiny-storepeer deps
npm i react react-dom
- Selector-driven updates with useSyncExternalStore hydration safety.
- Pure slice helpers plus controller hooks for side-effects.
- Tiny surface area — no reducers, actions, or global registries.
`tsx
import { createContextSync } from "@acoolhq/react-tiny-store";
type AppState = { count: number };
const { Provider, useSelector, bindActions } = createContextSync
const useCounter = bindActions((api) => ({
inc() {
api.set((prev) => ({ count: prev.count + 1 }));
},
}));
function Counter() {
const count = useSelector((s) => s.count);
const { inc } = useCounter();
return ;
}
export function App() {
return (
);
}
`
Issues and pull requests are welcome. Run npm run test:run` before opening a PR.
MIT