# SWR: 7.0 out of 10

A strong pick. 8th of 10 in [State and data fetching](https://elestia.ai/opensource/state-and-data/index.md).

SWR is Vercel's small React hook library for fetching and caching server data with stale-while-revalidate. It is a solid, light choice for read-heavy React and Next.js apps, but TanStack Query does the job better for most new apps that write data, need devtools or span frameworks.

**Best for:** React or Next.js teams with read-heavy apps who want a tiny, simple caching hook more than a full server-state toolkit.

## Scores

- **Overall: 7.0** (likely 6.0 to 8.0)
  - Claude Opus 5.5 (6.5): SWR is a good, safe, Vercel-backed library that does read-heavy React data fetching well with very little code. For most new apps, TanStack Query does the same job better, with stronger mutations, devtools and support for more frameworks, and it is growing faster. SWR is a reasonable pick for simple Next.js apps, but not the category default.
  - GPT-6.2 Sol (7.4): SWR is a strong new-project choice when React screens mostly need cached reads, automatic refresh, and occasional writes. TanStack Query is the stronger default when offline mutations, automatic cache eviction, or deeper cache controls matter. The range reflects how much an app benefits from a smaller bundle and how much of its work involves advanced cache behavior.
- **Needed by many: 5.7** (likely 4.7 to 6.7)
  - Claude Opus 5.5 (6.0): Most React apps need to fetch and cache server data, so the need is large. But SWR serves React only and caches server data, not general app state. That makes it narrower than the whole category.
  - GPT-6.2 Sol (5.4): Keeping server data fresh is a common need, and 42% of respondents to the 2026 Stack Overflow web technology question reported using React. SWR serves React clients, including React Native, and focuses on server data. Surveys give a useful measure of React's reach but leave open how many apps need a separate client cache.
- **Helps a lot: 7.2** (likely 6.1 to 8.2)
  - Claude Opus 5.5 (6.5): SWR does reads very well. It is small, has good TypeScript types, and supports Suspense, React 19 and RSC cache preloading. Independent comparisons agree that its mutations, invalidation of related keys and tooling are clearly behind TanStack Query. That puts it at good with clear limits.
  - GPT-6.2 Sol (7.8): Stable 2.5.1 has a compact typed API, request deduplication, background refresh, and optimistic rollback. Short examples give coding agents a clear starting point, though fetchers need to throw HTTP errors explicitly. An independent test found a smaller bundle than TanStack Query, but it used a synthetic workload. User reports flag infinite-list cache updates, and TanStack Query offers more cache controls and offline mutation support.
- **Holds up over time: 6.9** (likely 5.8 to 8.0)
  - Claude Opus 5.5 (7.0): Vercel funds SWR and uses it, and releases keep coming: 10 releases last year, v2.5.1 in August 2026 and a v2.6 beta in September. It stays on v2 with few breaking changes. But commit activity is low (58 against TanStack Query's 1,897), 106 pull requests are open, and the ecosystem is moving towards TanStack Query.
  - GPT-6.2 Sol (6.8): Vercel-backed SWR recorded 58 commits and 10 GitHub releases in a year, with an August patch and a September beta. Stable releases have stayed on 2.x, and recent patches fixed cache hydration and Suspense behavior. TanStack Query ships more actively, a proposed pagination fix has been open since October, and recent releases cluster around one maintainer. The public record gives limited visibility into who else can publish or how quickly the wider backlog moves.
- **Used widely: 6.5** (likely 5.4 to 7.6)
  - Claude Opus 5.5 (7.0): SWR had 108M downloads in the last 4 weeks. Its ratio of about 4.4 is just above the 4.1 median, so it holds ground but grows far slower than TanStack Query or Zustand (about 6.9). Part of the downloads likely comes from tools that install it, such as the Vercel AI SDK's React package. Its 39k dependent repos are a solid count of real use.
  - GPT-6.2 Sol (5.9): Ecosyste.ms found about 39,500 dependent repositories and 1,270 packages, which puts SWR in the middle of its peer group. Downloads grew 4.42×, just above the 4.1× catalog baseline and behind TanStack Query's 6.89×. Automated installs and packages such as Vercel's React AI SDK account for some of that volume, so the number of teams actively choosing SWR remains less certain.
- **Vouched for: 6.5** (likely 5.4 to 7.5)
  - Claude Opus 5.5 (6.0): Vercel builds and uses SWR, and many Next.js apps run it in production. Independent write-ups call it production-ready for read-heavy apps. In the State of React 2025 survey it trails TanStack Query, which leads data fetching on use and positive sentiment. Social attention is low: 5 Bluesky posts and no Hacker News stories.
  - GPT-6.2 Sol (6.9): Next.js documents SWR for client-side fetching, and Dub declares it as a direct dependency. An independent benchmark supports the small bundle, and some users report years of satisfactory use. Feedback on advanced caching is mixed, and TanStack Query leads satisfaction in State of React 2025.
- **Safe: 7.5** (likely 6.4 to 8.5)
  - Claude Opus 5.5 (7.5): SWR has no advisories, only two runtime dependencies and an MIT licence. Its OpenSSF Scorecard is a middling 5.5, with zero on token permissions, pinned dependencies and fuzzing. Its releases come from Vercel's CI.
  - GPT-6.2 Sol (7.4): SWR has an MIT licence, two runtime dependencies, and zero advisories in the collected OSV record. The project has a security policy and switched npm releases to trusted publishing in June. OpenSSF scored it 5.5, with zeroes for workflow token permissions, dependency pinning, and fuzzing. Those gaps and limited visibility into release access keep the range wide.

## Good

- It is very small (about 4-5 KB gzipped) and has only two runtime dependencies.
- The API is simple: useSWR(key, fetcher) gives caching, deduplication, focus revalidation and polling.
- It works closely with Next.js, including new RSC cache preloading in v2.5.
- Vercel backs it, and it has no known security advisories.

## Bad

- Mutations are basic: optimistic updates, rollback and invalidation are built by hand.
- There are no official devtools, and invalidating many related keys at once is awkward.
- It works only with React, while TanStack Query also covers Vue, Solid, Svelte and Angular.
- Development is slow: 58 commits last year and over 100 open pull requests.

## The numbers

- Downloads, 4 weeks: 108M
- In a year: ×4.4
- GitHub stars: 32k
- Commits, 12 months: 58
- Last npm release: Aug 2026
- Advisories, 24 months: 0
- Licence: MIT
- GitHub: https://github.com/vercel/swr
- npm: https://www.npmjs.com/package/swr

Scores run from 0 to 10 and are the mean of the scores of AI reviewers (Claude Opus 5.5, GPT-6.2 Sol), made on 21 November 2026 from GitHub, npm, OSV, OpenSSF Scorecard, ecosyste.ms, Hacker News and Bluesky data and a web search. The ecosyste.ms count of repositories that use a project is far too low for projects that grew in the last few years, and some reviews quote it. Overall is the reviewers' own judgement for a new project today, not an average of the parts. An AI wrote them and can be wrong.
