pkgdocs/compare/axios vs react-query

Comparing

npm

axios

Promise based HTTP client for the browser and node.js

101.0M/ wk
v1.14.0
vs
npm

react-query

Hooks for managing, caching and syncing asynchronous and remote data in React

1.6M/ wk
v3.39.3
Metricaxiosreact-query
Ecosystemnpmnpm
DifficultyAdvancedBeginner ✓
Weekly downloads101.0M↑1.6M
Latest versionv1.14.0v3.39.3
Recipes7↑1

Tags

axios only

httpapi-clientinterceptorspromiseisomorphicxhrajaxnodebrowser

Shared

fetch

react-query only

reactdata-fetchingcachingserver-stateasynctypescriptcachedatagraphql

When to use each

axios

Use axios when you need request/response interceptors (auth headers, logging, retry logic), want automatic JSON serialisation/deserialisation, need to cancel in-flight requests, or want consistent behaviour between browser and Node.js environments.

react-query

Use React Query for any React app that fetches server data: REST APIs, GraphQL, or any async function. It replaces 95% of the useEffect+useState patterns for data fetching and adds caching, background refetching, and optimistic updates for free.

When to skip each

axios

For simple requests in modern apps, fetch is built-in and perfectly adequate. For lightweight browser-only code, ky is a smaller alternative. React Query or SWR abstract data fetching further — prefer those when you also need caching and state management.

react-query

React Query is for server state (data that lives on a server). For UI state (modals, form values, local toggles), use useState or Zustand. If you're already using a full data layer like Apollo Client for GraphQL, React Query is redundant.

Sample recipes

axios

  • Install axios
  • Package manager
  • CDN
  • Example

+3 more

react-query

  • Install react-query