Skip to main content
Version: v10.0.0

React data fetching libraries compared

Picking a react data fetching library is mostly a question of what you already have. A Redux app, a GraphQL API, a REST backend with no client yet, a realtime feature next to plain HTTP calls. Each of the popular libraries answers a different version of that question, and the honest answer to "which one is best" is usually "the one that matches the rest of your stack".

This page puts the five libraries people compare most often next to each other. It says what each one is for, where it is strong, and links to a longer page for each head-to-head comparison.

What you'll learn
  1. What a data fetching library does that fetch alone does not.
  2. What TanStack Query, SWR, RTK Query and Apollo Client are each built for.
  3. Where HyperFetch fits, and where it does not.
  4. How to pick a React Query alternative based on your API and your app.

What a data fetching library does​

fetch sends one request and hands you a Response. Everything after that is your job: parse the body, check response.ok, keep a loading flag, cache the result so the next screen does not refetch it, refetch when the data goes stale, cancel the request when the component unmounts, retry when the network drops.

A data fetching library takes that list off your hands. The libraries below split into two groups:

  • Server-state managers (TanStack Query, SWR). They cache and sync whatever your function returns. You bring the HTTP call. They don't define what a request looks like.
  • API layers (RTK Query, Apollo Client, HyperFetch). You describe your endpoints or operations up front, and the library sends the request as well as caching the result.

Neither group is better. Server-state managers drop into any codebase because they don't care how you fetch. API layers give you more structure and less glue code, at the cost of adopting their way of describing requests.


The five libraries at a glance​

LibraryWhat it is forYou describe requests withFits best when
TanStack QueryCaching and syncing server state from any async functionA query key plus a query function you writeYou want the most widely used option and full control over the fetch call
SWRA small set of React hooks built around stale-while-revalidateA key (often the URL) plus a fetcherYou want a light hook for reads and very little setup
RTK QueryData fetching and caching built into Redux ToolkitAn API slice made with createApiYour app already runs on Redux
Apollo ClientA GraphQL client with a normalized cacheGraphQL documentsYour API is GraphQL
HyperFetchA typed request layer with cache, queues, offline support and socketsclient.createRequest() objects defined onceA REST or mixed API where you want requests, realtime and offline in one place

A few facts behind that table, each from the library's own docs:


Where HyperFetch fits​

HyperFetch is closest to RTK Query in shape. You define each request once, outside your components, and the request object carries its endpoint, method and types:

import { createClient } from "@hyper-fetch/core";

export const client = createClient({ url: "https://api.example.com" });

export const getUser = client.createRequest<{ response: User }>()({
endpoint: "/users/:userId",
method: "GET",
});

// Works anywhere: React, Node, a test, a script
const { data, error, status } = await getUser.setParams({ userId: 1 }).send();

In React, the same object goes into a hook:

import { useFetch } from "@hyper-fetch/react";

function Profile({ userId }: { userId: number }) {
const { data, loading, error } = useFetch(getUser.setParams({ userId }));
// ...
}

What sets it apart from the other four:

  • No Redux and no GraphQL requirement. The default adapter speaks HTTP through fetch. Swap in Axios, GraphQL or Firebase without changing how requests are used.
  • Realtime in the same model. The sockets package gives WebSocket and SSE listeners and emitters typed the same way as HTTP requests, and the GraphQL package adds subscriptions over graphql-transport-ws.
  • Request queues and offline handling. Requests sent while offline wait and go out when the connection returns, and a persistent queue keeps them through a reload. See offline and queueing.

And where it does not fit: HyperFetch has no normalized entity cache. If you need one record updated across every view that shows it, Apollo Client (for GraphQL) is built around that. Its UI bindings are React only, so a Vue or Svelte app is better served by TanStack Query.


Head-to-head comparisons​

Each page below opens with what the other library does well, compares the same tasks in code, and ends with concrete situations for picking either side.

HyperFetch vs TanStack Query
Query keys and query functions vs typed request objects. Caching, mutations, offline, devtools and frameworks.
HyperFetch vs SWR
A small stale-while-revalidate hook vs a full request layer. Where SWR is enough and where it stops.
HyperFetch vs RTK Query
Two libraries that define requests up front. One lives in Redux, one does not.
Axios vs fetch
What fetch leaves out, what Axios adds, and how to switch between them without touching your requests.
HyperFetch vs Apollo Client
A normalized GraphQL cache vs a cache per operation. Queries, mutations, subscriptions and when to stay on Apollo.
React Query Devtools vs HyperFlow
An in-app panel for the TanStack Query cache vs a desktop app for HyperFetch requests, cache, queues and sockets.

Which one fits you​

  • You use Redux already. Start with RTK Query. It ships in the package you already installed and its requests show up in Redux DevTools.
  • Your API is GraphQL and the same entities appear on many screens. Apollo Client and its normalized cache.
  • You want the most common choice, or you need Vue, Solid or Svelte. TanStack Query.
  • You only read a few endpoints and want almost no setup. SWR.
  • You have a REST API, want typed requests defined once, and also need sockets, upload progress or offline queues. HyperFetch. The quick start takes a few minutes, and Why HyperFetch lists its design decisions in detail.
Summary
  • Server-state managers (TanStack Query, SWR) cache what your own fetch function returns.
  • API layers (RTK Query, Apollo Client, HyperFetch) also define and send the request.
  • RTK Query fits Redux apps, Apollo Client fits GraphQL, TanStack Query is the widest-used general option.
  • HyperFetch fits typed REST and mixed APIs that need realtime, queues or offline support in one model.