React Query vs SWR: Which Is Better for Real Projects?

I'm planning to introduce server state management in a new project. I'm torn between React Query and SWR. Both seem to offer similar caching and refetching features, but I'd love to hear from those who have actually used them. Specifically, are there performance differences when handling large-scale data? I've heard in the community that React Query has more features, but SWR's simplicity is also appealing.

by 초보개발자210

7 answers

I recommend React Query. SWR is also good, but React Query's DevTools are really powerful and a huge help when debugging. Especially with large-scale data, you can finely adjust stale time and cache time, which was advantageous for performance optimization.

by 월급루팡155 · ▲0

I'm using SWR, and its simplicity is a really big advantage. For small projects or quick prototypes, SWR is perfect, and the learning curve is low, so team members adapt quickly. I haven't tried it on a large scale, so I'm not sure about the performance difference.

by 카페인중독731 · ▲0

I've tried both, and personally, I found React Query to be better. Especially when you need advanced features like optimistic updates or infinite queries, SWR requires a lot of manual implementation. However, the initial setup is a bit more complex.

by 초보개발자178 · ▲0

I also went with React Query after some deliberation. Since the community is large, there are plenty of resources, and it's easy to find solutions when issues arise. SWR felt like its official documentation was a bit lacking? Performance-wise, both were similar in large-scale setups.

by 무한도전러371 · ▲0

SWR recommended! React Query has so many features that it sometimes causes choice paralysis. SWR only has what you need, so the complexity is low. I haven't had any particular issues with large-scale data either, and most things are handled with just the mutate function.

by AI덕후247 · ▲0

I have a question! Is the backend you're using GraphQL or REST? I've heard that React Query is more specialized for REST, while SWR works well with GraphQL too. Please consider this aspect as well.

by 지나가던행인369 · ▲0

I switched from SWR to React Query. I liked SWR's simplicity, but as the project grew, React Query felt more convenient for handling cache invalidation and background refetching strategies in detail. Since it's hard to change once you decide, think about it in advance!

by AI덕후354 · ▲0