Skip to content

Apollo Client vs SWR

Which should you use? A side-by-side look at what each one does, who it suits, what it costs, how hard it is to set up, and where each falls short.

Apollo Client

Open source · MIT

A JavaScript and TypeScript library for loading and caching GraphQL data in web apps.

SWR

Open source · MIT

A React hook library for fetching data, with caching and automatic refresh.

The short answer

Choose Apollo Client if you need…

  • Developers building React apps that query a GraphQL API
  • Teams using TypeScript who want typed GraphQL operations
  • Apps that need a client-side cache for GraphQL responses

Choose SWR if you need…

  • React developers who fetch data from APIs in components
  • Projects that want built-in caching and request deduplication
  • Apps that need data to refresh on focus, network recovery, or polling
  • Teams building React Native or Next.js interfaces

Side-by-side

Apollo ClientSWR
TypeLibraryLibrary
PriceFree and open sourceFree and open source
LicenceMITMIT
GitHub stars19.8k32.5k
Setup difficultyIntermediateIntermediate
How you get itInstall with a package managerInstall with a package manager
Main languageTypeScriptTypeScript
Last code update6 days ago21 days ago

What each one is

Apollo Client

Apollo Client is a library that lets a front-end app fetch data from a GraphQL server and keep the results in a local cache. It works with React, Vue, Angular, and plain JavaScript, according to the README. The README says it offers caching, APIs for queries, and developer tools.

SWR

SWR is a React Hooks library for loading data in web interfaces. Its name comes from stale-while-revalidate: it shows cached data first, requests fresh data in the background, then updates the screen when the new data arrives. Developers use it to simplify data loading logic in React components.

Best for

Apollo Client

  • Developers building React apps that query a GraphQL API
  • Teams using TypeScript who want typed GraphQL operations
  • Apps that need a client-side cache for GraphQL responses

SWR

  • React developers who fetch data from APIs in components
  • Projects that want built-in caching and request deduplication
  • Apps that need data to refresh on focus, network recovery, or polling
  • Teams building React Native or Next.js interfaces

Strengths

Apollo Client

  • Caching is included out of the box, per the README
  • Works across several front-end frameworks
  • Has TypeScript support and an active maintainer team listed in the README

SWR

  • Small, focused API: one hook covers the common fetch, loading, and error cases
  • Built-in cache and request deduplication reduce repeated network calls
  • Works with any asynchronous fetcher, so you can use your preferred fetching library

Not ideal for

Apollo Client

  • Projects that do not use GraphQL, since the library is built around GraphQL queries
  • Developers who only need a simple HTTP request library, since this adds a larger set of concepts
  • Non-developers, because it is code you add to an app

SWR

  • People who do not write React code, since the library is built around React Hooks
  • Projects that need a full server-side data layer rather than client-side fetching hooks
  • Beginners with no JavaScript or React experience, who would need to learn those first

Trade-offs

Apollo Client

  • Requires understanding GraphQL and the library's caching model
  • The README is truncated, so the full feature list and edge cases are not covered here

SWR

  • Requires React knowledge; it is not useful outside React-style apps
  • The README is brief and points to the external documentation site for details and examples
  • Behavior such as caching and revalidation has settings that take time to learn

Getting started

Apollo Client

Install the client and GraphQL package

npm install @apollo/client graphql
Step-by-step guide: how to use Apollo Client

SWR

Install the package

npm install swr
Step-by-step guide: how to use SWR

Frequently asked questions

What is the difference between Apollo Client and SWR?

Apollo Client: A JavaScript and TypeScript library for loading and caching GraphQL data in web apps. SWR: A React hook library for fetching data, with caching and automatic refresh. Apollo Client suits developers building react apps that query a graphql api, while SWR suits react developers who fetch data from apis in components.

Are Apollo Client and SWR free?

Apollo Client: Free and open source. SWR: Free and open source.

Is Apollo Client or SWR more popular?

SWR has more GitHub stars (32.5k) than Apollo Client (19.8k). Popularity isn't the same as fit — check which one matches your use case above.

What are other alternatives to Apollo Client and SWR?

Other options people compare them with include Relay, Apollo Server, TanStack Query, useHooks, NativeBase.

Keep comparing

Built from our catalogue entries for both products: open-source details come from each project's README (AI-assisted, refreshed weekly) and GitHub data; AI-tool details are editorial. Spotted something wrong? Let us know from either product's page.