talira

Atomic state management for React

open sourceMITfree

Jotai is a state management library for React built on atoms: small pieces of state you create with atom() and read and write in components with useAtom, much like useState but shared across the app. Atoms can be derived from other atoms, computed asynchronously with React Suspense, or made write-only for actions, so state stays fine-grained without string keys or a single store. The core is about 2 kB, and extensions connect atoms to TanStack Query, tRPC, Immer, Redux, XState, Zustand, URL location and more. It's made by the Poimandres collective.

Problems it solves

  • share state between React components without prop drilling or a big Redux store
  • a lighter alternative to Recoil for global state in React
  • derive computed and async state in React that re-renders only what changed

Features

  • Primitive atoms used with useAtom like React's useState
  • Derived atoms computed from other atoms, including async ones with Suspense
  • Writable and write-only derived atoms for actions
  • Minimal core of about 2 kB with no string keys
  • Extensions for TanStack Query, tRPC, Immer, Redux, XState, Zustand, URL location and more

Alternatives

The same job

These do what Jotai does.

  1. Redux A JS library for predictable global state management
  2. Zustand Bear necessities for React state
  3. Valtio Proxy-based state for React and vanilla JavaScript
  4. MobX Simple, scalable state management
  5. Immer Work with immutable state by writing ordinary mutating code
  6. redux-persist Saves a Redux store to storage as it changes and restores it when the app starts

Compare Jotai with the top 3