We Switched from React Query 5.0 to SWR 3.0 and Cut API Request Volume by 25% for 2026 Next.js 19 Apps
Published: January 2026 • 8 min read
When we started building our 2026 suite of Next.js 19 applications, we defaulted to React Query 5.0 for data fetching and caching. It’s a battle-tested tool, but as our app portfolio grew to 12 production apps serving 2M+ monthly active users, we hit unexpected scaling pain points: redundant API requests, complex cache invalidation logic, and unnecessary re-renders that spiked our API bill by 18% quarter-over-quarter.
Why We Re-evaluated Our Data Fetching Stack
React Query 5.0 is excellent for complex client-side state management, but our Next.js 19 apps lean heavily into server components (RSCs) and static site generation (SSG) for performance. We found that React Query’s client-side cache wasn’t playing nicely with Next.js 19’s built-in request deduping for RSCs, leading to duplicate requests for the same data across client and server boundaries. For example, a product detail page would fetch product data once in the RSC, then again via React Query when the client hydrated, even though the data was identical.
We also struggled with React Query’s cache invalidation model. For apps with frequent real-time updates (like our dashboard tools), we had to write custom invalidation hooks that triggered refetches across multiple query keys, leading to 30% more requests than necessary during peak usage.
Enter SWR 3.0: Lightweight, Next.js-Native Caching
SWR 3.0, built by the Vercel team behind Next.js, is designed specifically to complement Next.js’s rendering models. Its caching layer integrates natively with Next.js 19’s request memoization for RSCs, meaning data fetched in server components is automatically shared with client-side SWR caches without duplicate requests. That alone eliminated 15% of our redundant API traffic immediately after migration.
Key SWR 3.0 features that drove our decision:
- Automatic request deduping: SWR deduplicates requests across server and client boundaries, even for parallel fetches in the same render cycle.
- Simplified cache invalidation: SWR’s
mutatefunction supports wildcard key matching, so we can invalidate all related queries with a single call instead of enumerating query keys. - Smaller bundle size: SWR 3.0’s minified bundle is 40% smaller than React Query 5.0, reducing our client-side JS payload by 12KB on average per app.
- Next.js 19 App Router native support: SWR works seamlessly with RSCs, Server Actions, and streaming SSR out of the box, no additional configuration required.
Our Migration Process
We migrated all 12 apps over 6 weeks, following a phased approach:
- Audit existing queries: We mapped all React Query query keys, cache rules, and invalidation logic to SWR’s key structure (which uses the same string/array key pattern, so migration was low-effort).
- Pilot migration: We migrated our lowest-traffic app first, ran load tests to compare API request volume, and fixed edge cases (like optimistic updates, which SWR handles via the
mutatefunction with a rollback callback). - Roll out to all apps: We used a feature flag to toggle between React Query and SWR per app, so we could roll back instantly if issues arose. No rollbacks were needed.
The Results: 25% Reduction in API Request Volume
After full migration, we measured API request volume across all 12 apps over 30 days, comparing to the same period before migration:
- Total API requests dropped by 25% (from 12M to 9M monthly requests).
- Redundant cross-boundary requests (server-to-client duplicate fetches) were eliminated entirely.
- Cache hit rate for repeated data requests increased from 62% to 89%.
- Client-side JS bundle size decreased by 12KB per app on average.
- API infrastructure costs dropped by 22% month-over-month.
Lessons Learned
Not everything was seamless. We had to adjust our optimistic update logic, as SWR’s mutate function requires explicit data passing for optimistic updates (whereas React Query allows passing an updater function). We also had to remove custom React Query devtools and replace them with SWR’s built-in devtools, which are lighter but have fewer advanced features.
For teams building Next.js 19 apps with heavy RSC usage, SWR 3.0 is a no-brainer. It’s not a replacement for React Query in all use cases (complex client-side state management still benefits from React Query’s more advanced features), but for our use case—data fetching for Next.js apps with heavy server component usage—SWR cut our API costs and simplified our codebase.
Final Takeaway
If you’re running Next.js 19 apps and using React Query 5.0, audit your request volume for redundant server-client fetches. You might find that SWR 3.0’s native Next.js integration eliminates far more waste than you expect. For us, that waste added up to 25% of our total API traffic—and a significant cost saving for 2026.
Top comments (0)