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) | RTK-Query (Website) | React Router (Website) | |
---|---|---|---|---|---|
Github Repo / Stars | |||||
Platform Requirements | React | React | React, GraphQL | Redux | React |
Their Comparison | (none) | (none) | Comparison | (none) | |
Supported Query Syntax | Promise, REST, GraphQL | Promise, REST, GraphQL | GraphQL, Any (Reactive Variables) | Promise, REST, GraphQL | Promise, REST, GraphQL |
Supported Frameworks | React | React | React + Others | Any | React |
Caching Strategy | Hierarchical Key -> Value | Unique Key -> Value | Normalized Schema | Unique Key -> Value | Nested Route -> value |
Cache Key Strategy | JSON | JSON | GraphQL Query | JSON | Route Path |
Cache Change Detection | Deep Compare Keys (Stable Serialization) | Deep Compare Keys (Stable Serialization) | Deep Compare Keys (Unstable Serialization) | Key Referential Equality (===) | Route Change |
Data Change Detection | Deep Comparison + Structural Sharing | Deep Compare (via stable-hash) | Deep Compare (Unstable Serialization) | Key Referential Equality (===) | Loader Run |
Data Memoization | Full Structural Sharing | Identity (===) | Normalized Identity | Identity (===) | Identity (===) |
Bundle Size | |||||
API Definition Location | Component, External Config | Component | GraphQL Schema | External Config | Route Tree Configuration |
Queries | ✅ | ✅ | ✅ | ✅ | ✅ |
Cache Persistence | ✅ | ✅ | ✅ | ✅ | 🛑 Active Routes Only 8 |
Devtools | ✅ | ✅ | ✅ | ✅ | 🛑 |
Polling/Intervals | ✅ | ✅ | ✅ | ✅ | 🛑 |
Parallel Queries | ✅ | ✅ | ✅ | ✅ | ✅ |
Dependent Queries | ✅ | ✅ | ✅ | ✅ | ✅ |
Paginated Queries | ✅ | ✅ | ✅ | ✅ | ✅ |
Infinite Queries | ✅ | ✅ | ✅ | 🛑 | 🛑 |
Bi-directional Infinite Queries | ✅ | 🔶 | 🔶 | 🛑 | 🛑 |
Infinite Query Refetching | ✅ | ✅ | 🛑 | 🛑 | 🛑 |
Lagged Query Data1 | ✅ | ✅ | ✅ | ✅ | ✅ |
Selectors | ✅ | 🛑 | ✅ | ✅ | N/A |
Initial Data | ✅ | ✅ | ✅ | ✅ | ✅ |
Scroll Recovery | ✅ | ✅ | ✅ | ✅ | ✅ |
Cache Manipulation | ✅ | ✅ | ✅ | ✅ | 🛑 |
Outdated Query Dismissal | ✅ | ✅ | ✅ | ✅ | ✅ |
Render Batching & Optimization2 | ✅ | ✅ | 🛑 | ✅ | ✅ |
Auto Garbage Collection | ✅ | 🛑 | 🛑 | ✅ | N/A |
Mutation Hooks | ✅ | ✅ | ✅ | ✅ | ✅ |
Offline Mutation Support | ✅ | 🛑 | 🟡 | 🛑 | 🛑 |
Prefetching APIs | ✅ | ✅ | ✅ | ✅ | ✅ |
Query Cancellation | ✅ | 🛑 | 🛑 | 🛑 | ✅ |
Partial Query Matching3 | ✅ | 🔶 | ✅ | ✅ | N/A |
Stale While Revalidate | ✅ | ✅ | ✅ | ✅ | 🛑 |
Stale Time Configuration | ✅ | 🛑7 | 🛑 | ✅ | 🛑 |
Pre-usage Query/Mutation Configuration4 | ✅ | 🛑 |