React state management libraries

Updated Nov 2026

React state management libraries hold shared state that components can read without passing props through every level of the component tree. Components use hooks to subscribe to selected store or atom values, where a change to a subscribed value triggers a re-render. These libraries keep data such as the signed-in user or a shopping cart in one place, where every screen of an app reads the same value.

Popularity

Zustand has the most monthly downloads in this comparison, at 346.8M.

LibraryMonthly downloadsStarsLast releaseLicense
Zustand
351.6M
58.9KNov 2026MIT
Redux Toolkit
186.4M
11.2KNov 2026MIT
TanStack Store
139.0M
916Sep 2026MIT
Nano Stores
76.6M
7.6KOct 2026MIT
Jotai
36.9M
21.3KNov 2026MIT
XState
31.2M
30.5KNov 2026MIT
MobX
17.7M
28.2KNov 2026MIT
Valtio
12.2M
10.2KMay 2026MIT
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

Zustand keeps application state in a store created by create, and the store itself is a React hook. A component calls the hook with a selector, such as (state) => state.bears, and renders again only when that selected value changes. No provider component wraps the app, and one store holds plain values, objects, and the functions that update them. Those functions call set, which merges the new values into the existing state one level deep.

Downloads / mo
351.6M
Stars
58.9K
Last release
5.1.0
License
MIT

Strengths

  • Reads state without provider wrappers. Read shared state through hooks without wrapping components in a provider.
  • Persists state with bundled middleware. Save selected store data to synchronous or asynchronous storage.

Limitations

  • Updates only merge one level. Copy nested objects explicitly when changing values inside them.

Quickstart

From README.md
$ npm install zustand
import { create } from 'zustand'

const useBearStore = create((set) => ({
  bears: 0,
  increasePopulation: () => set((state) => ({ bears: state.bears + 1 })),
  removeAllBears: () => set({ bears: 0 }),
}))

function BearCounter() {
  const bears = useBearStore((state) => state.bears)
  return <h1>{bears} around here ...</h1>
}

function Controls() {
  const increasePopulation = useBearStore((state) => state.increasePopulation)
  return <button onClick={increasePopulation}>one up</button>
}

Zustand examples

From open-source projects on GitHub

Redux Toolkit is the official package for writing Redux logic, and it replaces most of the setup that plain Redux needs. configureStore creates the store, and createSlice takes an initial state and a set of reducer functions and generates the matching action creators. Data from a server goes through RTK Query, a layer built into the package that handles requests, caching, loading state, and refetching. React apps also install React Redux, which the official templates configure alongside it.

Downloads / mo
186.4M
Stars
11.2K
Last release
2.14.0
License
MIT

Strengths

  • Includes request caching. Use RTK Query for loading, caching, invalidation, and refetching.
  • Generates reducers and action creators. Generate matching reducers and actions from a slice definition.

Limitations

  • State values should be serializable. Keep functions and other non-serializable values outside Redux state.
  • Persistence needs an additional package. Add a persistence library to save state across page reloads.

Quickstart

From GettingStarted.md
$ npm install @reduxjs/toolkit
import { createSlice, configureStore } from '@reduxjs/toolkit';

const counter = createSlice({
  name: 'counter',
  initialState: { value: 0 },
  reducers: {
    incremented(state) {
      state.value += 1;
    },
  },
});
const store = configureStore({ reducer: counter.reducer });
store.dispatch(counter.actions.incremented());
console.log(store.getState().value);

Redux Toolkit examples

From open-source projects on GitHub

TanStack Store

TanStack Store is an immutable, reactive data store that sits at the core of the other TanStack libraries. createStore defines the state, often outside any component, and setState replaces it with an updated copy. In React, useSelector reads one part of the store, and the component renders again only when that part changes. Adapters for Solid, Vue, Angular, and Svelte share the same store code.

Downloads / mo
139.0M
Stars
916
Last release
0.11.2
License
MIT

Strengths

  • Selector-scoped renders. A component that reads one field with useSelector skips renders caused by other fields.

Limitations

  • Renamed read hook. useStore remains only as a deprecated alias for useSelector, which new code calls instead.

Quickstart

From quick-start
$ npm install @tanstack/react-store
import { createStore, useSelector } from "@tanstack/react-store";

// You can instantiate the store outside of React components too!
export const store = createStore({
  dogs: 0,
  cats: 0,
});

// This will only re-render when `state[animal]` changes. If an unrelated store property changes, it won't re-render
const Display = ({ animal }) => {
  const count = useSelector(store, (state) => state[animal]);
  return <div>{`${animal}: ${count}`}</div>;
};

const updateState = (animal) => {
  store.setState((state) => {
    return {
      ...state,
      [animal]: state[animal] + 1,
    };
  });
};

TanStack Store examples

From open-source projects on GitHub

Nano Stores builds state from many small stores that live in plain modules outside components. An atom holds one value, read with get and changed with set, and computed derives a new store from others, such as the admins filtered from a list of users. Adapter packages, such as @nanostores/react, connect the same stores to React, Preact, Vue, Svelte, Solid, Lit, and Angular. The core has zero dependencies and stays under one kilobyte, minified and compressed.

Downloads / mo
76.6M
Stars
7.6K
Last release
1.5.5
License
MIT

Strengths

  • Shared across frameworks. One set of stores serves components written in React, Vue, Svelte, and other frameworks through small adapters.

Quickstart

From README.md
$ npm install nanostores
import { atom } from 'nanostores'

export const $counter = atom(0)

$counter.set($counter.get() + 1)

Nano Stores examples

From open-source projects on GitHub

Jotai stores state as atoms, each created by atom with an initial value such as a string, number, object, or array. Inside a component, useAtom returns the value and a setter, the same pair that useState returns. Passing a read function to atom creates a derived atom whose value comes from other atoms, and that function can be async to load data. Code refers to atoms as objects, with no string keys, unlike Recoil.

Downloads / mo
36.9M
Stars
21.3K
Last release
3.0.2
License
MIT

Strengths

  • Derives values from other atoms. Combine existing state values into values calculated from them.
  • Persists individual state values. Use atomWithStorage to save selected values across browser reloads.

Limitations

  • Atoms need stable references. Reuse atom objects across renders to avoid infinite render loops.
  • Stored values can mismatch HTML. Render storage-dependent content after browser state has loaded.

Quickstart

From App.tsx
$ npm install jotai
import { atom, useAtom } from 'jotai'

// Create your atoms and derivatives
const textAtom = atom('hello')
const uppercaseAtom = atom((get) => get(textAtom).toUpperCase())

// Use them anywhere in your app
const Input = () => {
  const [text, setText] = useAtom(textAtom)
  return <input value={text} onChange={(e) => setText(e.target.value)} />
}

const Uppercase = () => {
  const [uppercase] = useAtom(uppercaseAtom)
  return <div>Uppercase: {uppercase}</div>
}

// Now you have the components
const MyApp = () => (
  <div>
    <Input />
    <Uppercase />
  </div>
)

Jotai examples

From open-source projects on GitHub

XState models application logic as state machines and statecharts: named states, the events that move between them, and actors that run them. createMachine defines the states and transitions, createActor starts an actor from that definition, and send delivers an event such as { type: 'play' }. The package has no runtime dependencies and runs in frontend and backend code. For a plain store without machines, the same project publishes @xstate/store.

Downloads / mo
31.2M
Stars
30.5K
Last release
5.33.4
License
MIT

Strengths

  • Visual editor. Stately Studio draws machines as diagrams and edits them visually.

Limitations

  • Beta in the quick start. The README's quick start installs xstate@beta, the next major version, rather than the current stable release.

Quickstart

From README.md
$ npm install xstate
import { createActor, createMachine } from 'xstate';

const playerMachine = createMachine({
  initial: 'stopped',
  states: {
    stopped: {
      on: { play: { target: 'playing' } }
    },
    playing: {
      on: {
        pause: { target: 'paused' },
        stop: { target: 'stopped' }
      }
    },
    paused: {
      on: {
        play: { target: 'playing' },
        stop: { target: 'stopped' }
      }
    }
  }
});

const player = createActor(playerMachine).start();

player.send({ type: 'play' });
console.log(player.getSnapshot().value); // 'playing'

XState examples

From open-source projects on GitHub

MobX tracks which observable values each computation reads, so a React component wrapped in observer renders again only when those values change. makeAutoObservable turns an object's fields into observable state and its methods into actions. Updates are ordinary assignments, made from event handlers, timers, or asynchronous code. Derived values, called computeds, stay cached until the observables they read change. The state lives outside any UI framework, and the React bindings ship in the separate mobx-react-lite package.

Downloads / mo
17.7M
Stars
28.2K
Last release
7.1.7
License
MIT

Strengths

  • Tracks component dependencies automatically. Update React components when the state they read changes.
  • Caches values derived from state. Cache calculated values until the state they read changes.

Limitations

  • Async updates need action wrappers. Wrap state changes after await in runInAction.

Quickstart

From README.md
$ npm install mobx
import React from "react"
import ReactDOM from "react-dom"
import { makeAutoObservable } from "mobx"
import { observer } from "mobx-react-lite"

// Model the application state.
const myTimer = makeAutoObservable({
    secondsPassed: 0,
    increase() {
        this.secondsPassed += 1
    },
    reset() {
        this.secondsPassed = 0
    }
})

// Build a "user interface" that uses the observable state.
const TimerView = observer(({ timer }) => (
    <button onClick={() => timer.reset()}>Seconds passed: {timer.secondsPassed}</button>
))

ReactDOM.render(<TimerView timer={myTimer} />, document.body)

// Update the 'Seconds passed: X' text every second.
setInterval(() => {
    myTimer.increase()
}, 1000)

MobX examples

From open-source projects on GitHub
resetForm() {
    this.fields.clear();
    this.errors.clear();
    this.fieldState.clear();
    this.snapshots = [];
    this.initialData = {};
  }

Valtio wraps a plain object in a proxy with proxy, and code changes it by assigning to its fields from anywhere, such as a timer callback. In a component, useSnapshot returns a read-only snapshot and renders the component again only when a field it read has changed. Outside React, subscribe runs a callback on every change to the whole state or to one nested object.

Downloads / mo
12.2M
Stars
10.2K
Last release
2.3.2
License
MIT

Strengths

  • Direct mutation. Event handlers and plain functions change state by assigning to the proxy's fields.

Limitations

  • Snapshots are frozen. A method called on a snapshot can't change state. The README recommends arrow functions that change the proxy directly.

Quickstart

From README.md
$ npm install valtio
import { proxy, useSnapshot } from 'valtio'

const state = proxy({ count: 0, text: 'hello' })

// This will re-render on `state.count` change but not on `state.text` change
function Counter() {
  const snap = useSnapshot(state)
  return (
    <div>
      {snap.count}
      <button onClick={() => ++state.count}>+1</button>
    </div>
  )
}

Valtio examples

From open-source projects on GitHub

FAQ

For one shared store read through hooks, Zustand needs no provider component. Jotai keeps many small values as atoms that combine into derived ones, and Redux Toolkit adds RTK Query for loading and caching server data. MobX and Valtio let code change state by plain assignment.

Zustand stores state in a hook that any component calls without a provider, and the functions that update the state live in the same store. Redux Toolkit is the official way to write Redux logic: createSlice generates actions and reducers, and RTK Query handles server data. An app that already uses Redux keeps its store and moves to Redux Toolkit.

Zustand keeps state in one store, and each component selects the part it reads. Jotai keeps each value in its own atom, used like useState, and builds derived atoms from other atoms. Both libraries work without a provider component.

React Context passes a value through the component tree with no extra package. Zustand's README lists three differences from Context: less boilerplate, components that render only on changes, and centralized, action-based updates.

TanStack Store is an immutable, reactive data store that sits at the core of the other TanStack libraries. Its React adapter reads state with useSelector, which renders a component again only when the selected value changes.

MobX tracks which observable values each component reads, so updates are plain assignments and only the affected components render again. Redux Toolkit routes every change through actions and reducers defined in slices, and its usage guide keeps state to serializable values.

For coding agents

Found your state management library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official