Zustand

A small, fast React state management library with a hook-based API and no boilerplate.

Library
npm
v5.0.15
58,802 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
78 /100 Good
Development Activity 72
Maintenance 76
Community 64
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
90 /100 Excellent
Architecture 90
Code Quality 85
Innovation 88
Learning Curve 95

Zustand is a minimal state-management library for React (and vanilla JS) built on simplified flux principles. It exposes a single create() function that returns a hook-shaped store — no context providers, no reducers, no action-type boilerplate — while still supporting selectors, middleware, and fully-typed TypeScript usage for larger applications.

Under the hood it is a closure-based store with a listener set, wrapped by a thin adapter over React’s useSyncExternalStore, which keeps the runtime tiny while remaining framework-agnostic at its core (the vanilla store can be used entirely outside React).

What You Get

  • A create() API that returns a ready-to-use React hook backed by a vanilla, framework-agnostic store
  • Selector-based subscriptions so components only re-render when the slice of state they read changes
  • Official middleware for persistence (persist), Redux DevTools integration (devtools), Immer-based immutable updates (immer), and combining reducers (redux, combine)
  • A separate vanilla entry point for using the store outside React (vanilla JS, other frameworks, or server-side logic)
  • Full TypeScript support with typed middleware composition via StateCreator generics

Common Use Cases

  • Replacing prop drilling or React Context for shared UI state (modals, theming, auth session) without a provider tree
  • Mid-sized to large React apps that want Redux-like predictability (single store, explicit updates) without Redux’s boilerplate
  • Persisting user preferences or session state to localStorage/AsyncStorage via the persist middleware
  • Sharing state between React and non-React code (e.g. a vanilla JS widget or a Node script) via the same store instance

Under The Hood

Architecture — Zustand’s core is a minimal vanilla store (src/vanilla.ts, ~100 lines) implementing createStore with a closure-based state container: a mutable state variable, a Set of listener callbacks, and setState/getState/getInitialState/subscribe methods — no reducers, no action types, no context. The React binding (src/react.ts) is a thin ~64-line wrapper around React’s built-in useSyncExternalStore hook, adding a selector argument for slice-based re-rendering and memoized snapshot getters. This two-layer split (framework-agnostic vanilla store + tiny React adapter) is the architectural core: create() composes createStore() from vanilla.ts and exposes it as a callable hook that also carries the raw store API as static properties via Object.assign. Middleware (src/middleware/*.ts: persist.ts, devtools.ts, immer.ts, redux.ts, combine.ts, subscribeWithSelector.ts) wraps StateCreator functions functionally, decorating setState/getState before they reach the store, which is how cross-cutting concerns like localStorage persistence or Redux DevTools integration are added without touching the core.

Tech Stack — Written in TypeScript (97.9% of the codebase per GitHub language stats), targeting Node >=12.20.0. Zero runtime dependencies; react, immer, and use-sync-external-store are all optional peerDependencies (peerDependenciesMeta marks them optional), which lets the vanilla store be imported without pulling in React at all. Build tooling uses Rollup (rollup.config.mjs) with esbuild for transpilation, producing separate CJS/ESM bundles per entry point (index, vanilla, react, middleware, shallow, traditional) as declared in the exports map in package.json. The repo uses pnpm workspaces (pnpm-workspace.yaml) and Vitest for testing.

Code Quality — 12 test files in tests/ (basic.test.tsx, ssr.test.tsx, devtools.test.tsx, immer.test.tsx, persistAsync.test.tsx, persistSync.test.tsx, shallow.test.tsx, subscribe.test.tsx, middlewareTypes.test.tsx, types.test.tsx) cover both runtime behavior and TypeScript type-level correctness, run via Vitest with a dedicated test:types script (tsc --noEmit) enforcing type soundness on every change. ESLint (flat config) plus Prettier enforce style; naming is short and consistent (create, useStore, setState) matching the library’s minimal-surface philosophy. Core state files carry inline comments explaining non-obvious TypeScript workarounds (e.g. a TODO on setState’s type assertion referencing a specific upstream TypeScript issue), showing deliberate handling of edge cases rather than silent suppression.

API Design — The public API is intentionally tiny: create((set, get) => ({...})) returns a hook usable directly in components with no provider wrapper, no action-type boilerplate, and immutable updates handled by a shallow-merging set function. Selector support (useStore(state => state.slice)) is opt-in and additive rather than required. Middleware composes via simple functional wrapping (persist(devtools(store))) rather than a plugin-registration system, so users add functionality by wrapping, not configuring. TypeScript generics are heavy (StateCreator, Mutate, StoreMutators) to support fully-typed middleware chains, which adds type-signature complexity for advanced users but keeps the runtime API surface small; the getting-started docs get a new user to a working store in under 10 lines of code.

Used by 119 apps in this directory

TypeScript
98%
MIT

Kimi Code CLI

AI Agents · AI Code Assistants · Developer Tools

7,813

A single-binary, terminal-native coding agent that reads, edits, and runs code end to end, built by Moonshot AI for Kimi models but pluggable with Anthropic, OpenAI, and Google providers too.

View details
83
Repo Health
87
Technical
67
Dependency
Built with
TypeScript 98%
Updated today
TypeScript
64%
Apache 2.0

Laminar

AI Development · Monitoring

3,368

Open-source observability platform purpose-built for AI agents — trace, evaluate, debug, and monitor at scale with SQL access and real-time replay.

View details
85
Repo Health
76
Technical
66
Dependency
Built with
TypeScript 64%
Rust 34%
Updated yesterday
Python
69%
MIT

Langflow

AI Agents · AI Development

155,451

Build, test, and deploy AI agents and RAG workflows visually with native API and MCP server export.

View details
90
Repo Health
85
Technical
65
Dependency
Built with
Python 69%
TypeScript 22%
Updated today
TypeScript
97%
Other

Langfuse

AI Development · Monitoring

35,581

Open source AI engineering platform for LLM observability, prompt management, evaluation, and debugging — self-host in minutes or use Langfuse Cloud.

View details
92
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 97%
Updated today
TypeScript
96%
AGPL 3.0

Libra AI

AI Development · No Code Platforms

1,687

Open-source AI-powered platform that generates and deploys full-stack web applications from natural language prompts, built natively for Cloudflare Workers.

View details
31
Repo Health
71
Technical
68
Dependency
Built with
TypeScript 96%
Updated 1 years ago
Python
56%
MIT

LibrePhotos

File Storage

8,098

Self-hosted photo library with AI-powered face recognition, semantic search, and automatic event albums — no cloud required.

View details
84
Repo Health
78
Technical
66
Dependency
Built with
Python 56%
TypeScript 43%
Updated today
TypeScript
93%
AGPL 3.0

Linkwarden

Bookmarks Archiving · Knowledge Management

20,026

Self-hosted collaborative bookmark manager that captures full-page archives, enables annotation, and keeps your knowledge accessible forever.

View details
89
Repo Health
72
Technical
66
Dependency
Built with
TypeScript 93%
Updated 1 weeks ago
Go
42%
AGPL 3.0

listmonk

Blogging · Marketing

23,727

High-performance, self-hosted newsletter and mailing list manager packaged as a single binary with built-in analytics, transactional messaging, and multi-channel delivery.

View details
81
Repo Health
74
Technical
67
Dependency
Built with
Go 42%
Vue 24%
JavaScript 19%
Updated 3 days ago
TypeScript
98%
Other

LobeHub

AI Assistants · Automation · Productivity

83,091

Your Chief Agent Operator — build, schedule, and collaborate with an entire AI team in one self-hostable workspace.

View details
92
Repo Health
81
Technical
66
Dependency
Built with
TypeScript 98%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers