react-query vs jotai vs mobx-react vs mobx-react-lite vs react-redux vs recoil vs redux vs zustand
State Management and Data Fetching Solutions for React Applications
react-queryjotaimobx-reactmobx-react-litereact-reduxrecoilreduxzustandSimilar Packages:

State Management and Data Fetching Solutions for React Applications

jotai, mobx-react, mobx-react-lite, react-redux, recoil, redux, and zustand are state management libraries designed to handle application state in React, while react-query specializes in server state management, including data fetching, caching, and synchronization. These libraries address different aspects of state: some focus on local UI state, others on global state, and react-query specifically handles asynchronous server state with built-in caching, background updates, and optimistic updates.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
react-query1,630,39148,7652.26 MB1743 years agoMIT
jotai021,038519 kB4a day agoMIT
mobx-react028,184650 kB865 months agoMIT
mobx-react-lite028,184424 kB865 months agoMIT
react-redux023,509823 kB38a year agoMIT
recoil019,5222.21 MB3223 years agoMIT
redux061,443290 kB432 years agoMIT
zustand057,31395 kB5a month agoMIT

State Management & Data Fetching in React: A Deep Dive into 8 Key Libraries

Managing state in React apps isn’t one-size-fits-all. Some libraries handle local UI state, others global client state, and a few specialize in server state. Let’s compare how each of these eight packages tackles real-world problems.

🧠 Core Philosophy: How Each Library Thinks About State

redux treats state as a single, immutable tree. Every change requires a pure reducer function and an action object.

// redux
const increment = { type: 'INCREMENT' };
const counterReducer = (state = 0, action) => {
  if (action.type === 'INCREMENT') return state + 1;
  return state;
};

react-redux is just the React binding for Redux — it doesn’t manage state itself but connects Redux stores to components.

// react-redux
import { useSelector, useDispatch } from 'react-redux';
function Counter() {
  const count = useSelector(state => state.counter);
  const dispatch = useDispatch();
  return <button onClick={() => dispatch(increment)}>{count}</button>;
}

zustand uses a single store with direct setter functions. No actions, no reducers — just a hook that gives you state and setters.

// zustand
import { create } from 'zustand';
const useStore = create((set) => ({
  count: 0,
  inc: () => set((state) => ({ count: state.count + 1 }))
}));
function Counter() {
  const { count, inc } = useStore();
  return <button onClick={inc}>{count}</button>;
}

jotai models state as “atoms” — tiny units of state that can be read, written, or derived. No provider needed.

// jotai
import { atom, useAtom } from 'jotai';
const countAtom = atom(0);
const Counter = () => {
  const [count, setCount] = useAtom(countAtom);
  return <button onClick={() => setCount(c => c + 1)}>{count}</button>;
};

recoil also uses atoms and selectors, but requires a <RecoilRoot> provider at the top of your app.

// recoil
import { atom, useRecoilState } from 'recoil';
const countAtom = atom({ key: 'count', default: 0 });
const Counter = () => {
  const [count, setCount] = useRecoilState(countAtom);
  return <button onClick={() => setCount(c => c + 1)}>{count}</button>;
};

mobx-react and mobx-react-lite rely on MobX’s observable state. You mutate state directly, and React components automatically re-render when observed values change.

// mobx-react-lite
import { observer } from 'mobx-react-lite';
import { makeAutoObservable } from 'mobx';
class Store {
  count = 0;
  constructor() { makeAutoObservable(this); }
  inc = () => { this.count += 1; };
}
const store = new Store();
const Counter = observer(() => (
  <button onClick={store.inc}>{store.count}</button>
));

react-query doesn’t manage client state — it manages server state. You define queries, and it handles fetching, caching, background updates, and more.

// react-query
import { useQuery } from '@tanstack/react-query';
function UserProfile({ userId }) {
  const { data, isLoading } = useQuery({
    queryKey: ['user', userId],
    queryFn: () => fetchUser(userId)
  });
  if (isLoading) return <div>Loading...</div>;
  return <div>{data.name}</div>;
}

🔌 Setup Overhead: Providers, Stores, and Boilerplate

  • redux + react-redux: Requires creating a store, wrapping your app in <Provider>, defining actions/reducers, and connecting components.
  • zustand: Zero providers. Just call create() and use the hook anywhere.
  • jotai: No provider needed (unless using advanced features like persistence).
  • recoil: Must wrap your app in <RecoilRoot>.
  • mobx-react: Needs <Provider> if using inject; otherwise, just pass stores via props or module imports.
  • mobx-react-lite: No provider needed — just use observer on components.
  • react-query: Requires <QueryClientProvider> at the root, but that’s it.

📈 Performance: Re-render Behavior

All modern libraries avoid unnecessary re-renders, but they do it differently:

  • redux/react-redux: Components re-render only if the slice they select changes (thanks to shallowEqual by default).
  • zustand: Uses a selector pattern — only re-renders if the selected state changes.
  • jotai and recoil: Subscribe components only to the specific atoms they use.
  • mobx-react-lite: Automatically tracks which observables a component uses and re-renders only when those change.
  • react-query: Caching means components often get data instantly from cache, avoiding loading spinners and extra renders.

🔄 Async and Derived State

Need computed values or async data?

jotai supports async atoms and derived atoms natively:

// jotai async atom
const userAtom = atom(async (get) => {
  const id = get(userIdAtom);
  const res = await fetch(`/api/user/${id}`);
  return res.json();
});

recoil uses selectors for derived state and async queries:

// recoil selector
const userNameSelector = selector({
  key: 'userName',
  get: async ({ get }) => {
    const user = await fetchUser(get(userIdAtom));
    return user.name;
  }
});

mobx lets you create computed properties:

// mobx computed
class UserStore {
  @observable users = [];
  @computed get activeUsers() {
    return this.users.filter(u => u.active);
  }
}

react-query is built for async — it handles retries, stale-while-revalidate, pagination, and mutations out of the box.

redux typically needs middleware like redux-thunk or redux-saga for async logic, though Redux Toolkit simplifies this.

zustand can handle async in setters:

// zustand async
const useStore = create((set) => ({
  user: null,
  fetchUser: async (id) => {
    const user = await api.getUser(id);
    set({ user });
  }
}));

⚠️ Important Notes on Maintenance and Use

  • mobx-react includes legacy APIs (Provider/inject) that are rarely needed in modern React. Prefer mobx-react-lite for function components.
  • recoil development has significantly slowed since mid-2023, with Meta recommending alternatives like Jotai for new projects.
  • redux is not deprecated — but Redux Toolkit is now the standard way to use it, reducing boilerplate dramatically.
  • react-query (now part of TanStack Query) is actively maintained and widely adopted for server state.

🤝 When to Combine Libraries

It’s common — and often smart — to use more than one:

  • Use react-query for server data + zustand or jotai for client UI state.
  • Avoid using redux for server state — that’s what react-query is for.
  • Don’t mix mobx and redux — they solve the same problem with opposite philosophies (mutable vs immutable).

📊 Summary Table

LibraryState TypeProvider Needed?Async Built-in?Best For
reduxGlobal clientYes (via react-redux)No (needs middleware)Large apps needing strict predictability
react-reduxReact binding onlyYesNoConnecting Redux to React
zustandGlobal clientNoYes (in setters)Simple, hook-based global state
jotaiAtomic clientNoYesFine-grained, modern state without providers
recoilAtomic clientYesYesLarge apps with complex derived state (use cautiously)
mobx-reactObservable clientOptionalYes (via reactions)Legacy class-component apps
mobx-react-liteObservable clientNoYesModern MobX apps with function components
react-queryServerYesYesAny app that fetches data from APIs

💡 Final Guidance

  • For server data: Always start with react-query. It solves problems you didn’t know you had (stale data, background refetching, etc.).
  • For simple client state: zustand or jotai will save you hours of boilerplate.
  • For complex enterprise apps with audit needs: redux + Redux Toolkit still shines.
  • For reactive, mutable state lovers: mobx-react-lite is clean and powerful.
  • Avoid recoil for new greenfield projects unless you have a strong reason — its future is uncertain.

The best architecture often uses two tools: one for server state (react-query) and one for client state (zustand, jotai, or redux). Trying to force everything into one system usually leads to pain.

How to Choose: react-query vs jotai vs mobx-react vs mobx-react-lite vs react-redux vs recoil vs redux vs zustand

  • react-query:

    Choose react-query when your app heavily relies on server data — fetching, caching, background updates, pagination, mutations, and more. It eliminates the need to manually manage loading states, refetching logic, or cache invalidation. Essential for data-intensive applications with complex server interactions.

  • jotai:

    Choose jotai if you want a minimal, atomic state model inspired by Recoil but without the need for a root provider. It integrates well with Concurrent React and supports derived atoms and async atoms out of the box. Ideal for teams seeking a lightweight, modern alternative to Redux or Context API with less boilerplate.

  • mobx-react:

    Choose mobx-react if you're already using MobX for state management and need full integration with class components and legacy React patterns. However, note that this package is heavier than mobx-react-lite and includes features like Provider and inject that are unnecessary for most modern function component-based apps.

  • mobx-react-lite:

    Choose mobx-react-lite if you're using MobX with function components and hooks. It provides the essential observer HOC and useLocalObservable hook without the overhead of legacy APIs. Best for projects that benefit from MobX’s mutable, reactive programming model and automatic tracking.

  • react-redux:

    Choose react-redux if you're using Redux and need official, optimized bindings for React. It provides hooks like useSelector and useDispatch and ensures efficient re-renders. Use it when your team values Redux’s strict unidirectional data flow, middleware ecosystem (like Redux Toolkit), and dev tools.

  • recoil:

    Choose recoil if you prefer a fine-grained, atom-based state model with selectors for derived state and built-in async support. It avoids global re-renders by subscribing components only to the atoms they use. Best for large apps where performance and state composition are critical, though development has slowed since 2023.

  • redux:

    Choose redux if you need a predictable, centralized store with strict immutability, middleware support, and time-travel debugging. It’s best paired with Redux Toolkit to reduce boilerplate. Suitable for complex applications requiring strong state consistency, auditability, and large-scale team coordination.

  • zustand:

    Choose zustand if you want a simple, hook-based global state solution without providers or context. It uses a single store with direct mutation support (via immer-style updates) and avoids re-rendering unrelated components. Great for small to medium apps or teams tired of Redux boilerplate.

README for react-query

React Query Header

Note

You're looking at the v3 version of react-query. Starting with v4, react-query is now available as @tanstack/react-query

Find the docs at https://tanstack.com/query/latest