JotaiJotai

状態
Primitive and flexible state management for React

Documentation

Welcome to the Jotai v2 documentation! Jotai's atomic approach to global React state management scales from a simple useState replacement to an enterprise application with complex requirements.

Features

  • Minimal core API (2kb)
  • Many utilities and extensions
  • TypeScript oriented
  • Works with Next.js, Waku, Remix, and React Native

Core

Jotai has a very minimal API, exposing only a few exports from the main jotai bundle. They are split into four categories below.

atom
useAtom
Store
Provider

Utilities

Jotai also includes a jotai/utils bundle with a variety of extra utility functions. One example is atomWithStorage, which includes localStorage persistence and cross browser tab synchronization.

Storage
SSR
Async
Lazy
Resettable
Family

Extensions

Jotai has many officially maintained extensions including atomWithQuery for React Query and atomWithMachine for XState, among many others.

tRPC
Query
Effect
URQL
Immer
XState
Location
Cache
Scope
Optics

Third-party

Beyond the official extensions, there are many third-party community packages as well.

History
Derive
Bunja

Tools

Use SWC and Babel compiler plugins for React Fast Refresh support and debugging labels. This creates the best developer experience when using a React framework such as Next.js or Waku.

SWC
Babel
Devtools

Basics

Learn the basic concepts of the library, discover how it compares with others, and see usage examples.

概念
比较
案例
Functional programming and Jotai

Guides

Guides can help with use common cases such as TypeScript, React frameworks, and basic patterns.

异步
TypeScript
调试
持久化
Next.js
React Native
可复位
原子中的 Atom
测试
Vite
内部核心
组合 atom
在 Render 中初始化 Atom State
性能
迁移到 Jotai v2 API
Waku
Remix

Recipes

Recipes can help with more advanced patterns.

Large objects
Custom useAtom hooks
useAtomEffect
atomWithToggle
atomWithCompare
atomWithToggleAndStorage
atomWithRefresh
atomWithRefreshAndDefault
atomWithListeners
atomWithBroadcast
atomWithDebounce
useReducerAtom