This comparison table strives to be as accurate and as unbiased as possible. If you use any of these libraries and feel the information could be improved, feel free to suggest changes (with notes or evidence of claims) using the "Edit this page on Github" link at the bottom of this page.
Feature/Capability Key:
React Query | SWR (Website) | Apollo Client (Website) | |
---|---|---|---|
Supported Protocol | HTTP | HTTP | GraphQL |
Supported Query Signatures | Promise | Promise | GraphQL Query |
Supported Query Keys | JSON | JSON | GraphQL Query |
Query Key Change Detection | Deep Compare (Serialization) | Referential Equality (===) | Deep Compare (Serialization) |
Bundle Size | |||
Queries | ✅ | ✅ | ✅ |
Caching | ✅ | ✅ | ✅ |
Devtools | ✅ | 🟡 | ✅ |
Polling/Intervals | ✅ | ✅ | ✅ |
Parallel Queries | ✅ | ✅ | ✅ |
Dependent Queries | ✅ | ✅ | ✅ |
Paginated/Infinite Queries | ✅ | ✅ +(~2kb) | ✅ |
Initial Data | ✅ | ✅ | ✅ |
Scroll Recovery | ✅ | ✅ | ✅ |
Cache Manipulation | ✅ | ✅ | ✅ |
Outdated Query Dismissal | ✅ | ✅ | ✅ |
Auto Garbage Collection | ✅ | 🛑 | 🛑 |
Mutation Hooks | ✅ | 🛑 | ✅ |
Prefetching APIs | ✅ | 🔶 | ✅ |
Query Cancellation | ✅ | 🛑 | 🛑 |
Partial Query Matching1 | ✅ | 🛑 | 🛑 |
Window Focus Refetching | ✅ | ✅ | 🛑 |
Network Status Refetching | 🛑 | ✅ | ✅ |
Automatic Refetch after Mutation2 | 🔶 | 🔶 | ✅ |
Cache Dehydration/Rehydration | 🛑 | 🛑 | ✅ |
React Suspense (Experimental) | ✅ | ✅ | 🛑 |
1 Partial query matching - Because React Query uses deterministic query key serialization, this allows you to manipulate variable groups of queries without having to know each individual query-key that you want to match, eg. you can refetch every query that starts with
todos
in its key, regardless of variables, or you can target specific queries with (or without) variables or nested properties, and even use a filter function to only match queries that pass your specific conditions.
2 Automatic Refetch after Mutation - For truly automatic refetching to happen after a mutation occurs, a schema is necessary (like the one graphQL provides) along with heuristics that help the library know how to identify individual entities and entities types in that schema.
The latest TanStack news, articles, and resources, sent to your inbox.