Zustand is a small, fast, and scalable state management library for React and vanilla JavaScript, built on simplified Flux principles. It provides a hooks-first API with no providers or boilerplate, using `create` to define stores and `useStore` to subscribe to state slices. The library supports middleware composition (persist, devtools, immer, redux, subscribeWithSelector, combine, ssrSafe) and offers first-class TypeScript support with advanced type inference patterns. The core architecture consists of a vanilla store (`createStore`) that manages state, setters, getters, and subscriptions, and a React binding that leverages `useSyncExternalStore` for concurrent-safe rendering. Middleware are implemented as higher-order functions that wrap the store creator, enabling features like persistence to localStorage, Redux DevTools integration, immutable updates via Immer, and granular subscriptions with custom equality. The codebase is well-structured, thoroughly tested, and actively maintained with a mature API that has evolved through multiple major versions.
This is the official React-Redux library, providing bindings for React components to connect to a Redux store. The source code defines the core public API: `<Provider>` component, `connect()` HOC, React hooks (`useSelector`, `useDispatch`, `useStore`), `shallowEqual`, and `batch`. Under the hood, it implements a custom subscription system (`Subscription.ts`) for correct nested component update ordering, a context-based store propagation mechanism, and a variety of selector factories and memoization utilities. The library is fully typed with TypeScript, includes extensive unit and integration tests, and supports both React 18 and 19, as well as limited React Server Components. The architecture is modular but tightly coupled to Redux semantics; no external dependencies beyond React and Redux. The codebase is actively maintained, uses modern tooling (Vitest, tsup, API Extractor), and has a small set of deprecated APIs (e.g., `batch`, `connect` with `withRef`).