// the find
bcherny/undux
⚡️ Dead simple state for React. Now with Hooks support.
Undux is a small React state library where you declare a typed model once with createConnectedStore, then read and write keys through get and set from hooks or withStore. Its subscriptions are a minimal Rx-style observable, so side effects can be written as RxJS pipelines without a reducer or action layer. It suits teams who find Redux more ceremony than their app needs.
The type-safety claim is tested, not just asserted: test/bad-cases holds Flow files that exist to fail on wrong keys and wrong value types, which is more than most small libraries bother with. Partial application of set (store.set('one') returns a setter) removes most of the onChange wiring from forms. Effects are plain functions over the store, using on(key) and onAll(), so side-effect logic stays out of components and is easy to unit test. Redux DevTools and the console logger are store wrappers passed to createConnectedStore, so debugging does not touch call sites.
The last push was May 2025, about seventeen months before today, and nothing in the metadata suggests recent activity, so adopting it means owning it. The effects story leans on RxJS, which the library deliberately does not bundle; the README's own debounce examples need a separate install, and the built-in observable is a second, smaller API to learn. The docs disagree on the hook pattern: the basic example uses const store = useStore() while the TypeScript recipe uses const { store } = useStore(), and someone copying one or the other will hit a type error. Flow is still advertised next to TypeScript, with a flow-typed directory and a badge, so the typing surface is two systems to keep correct.