React Query vs SWR: Which One's More Popular These Days?

I'm currently deciding on a server state management library for the frontend. I've heard React Query has strong caching strategies, while SWR is said to pair well with Next.js... But I'm building a simple dashboard, so I don't need complex features. Could anyone who has used both give me a recommendation? I'm also curious about the learning curve and debugging difficulty.

by 월급루팡751

9 answers

I built a dashboard using Next.js + SWR, and it was really simple and great. With SWR's mutate function, I easily implemented optimistic updates and the amount of code was significantly reduced. There's almost no learning curve.

by 취준생김씨727 · ▲0

I've used both libraries, and for a simple dashboard, I recommend SWR. React Query has so many features that it can actually lead to over-engineering. SWR's code is intuitive and integrates naturally with Next.js.

by 월급루팡232 · ▲0

It's true that React Query is more popular, but the best choice depends on your situation. For simple CRUD like a dashboard, SWR is lightweight and great; if you need complex cache invalidation, React Query is the answer.

by 호기심천국74 · ▲0

I highly recommend React Query. Its caching strategy is really powerful, making data refetching management on dashboards super convenient. There's a bit of a learning curve at first, but the official documentation is well-written, so you can pick it up quickly.

by 취준생김씨631 · ▲0

I've used both, and React Query DevTools is much better for debugging. SWR is a bit inconvenient for checking state. Even if it's a dashboard, considering that features might be added later, React Query might be the better choice.

by 무한도전러704 · ▲0

Have you understood the concepts of staleTime and gcTime in React Query? They're key but can be a bit confusing at first. For a dashboard, the default values are usually sufficient, but since SWR is more intuitive, I'd recommend SWR for beginners.

by 월급루팡40 · ▲0

I personally prefer React Query because its TypeScript support is better. If type safety is important in your dashboard, React Query is the better choice; otherwise, SWR is also fine.

by 데이터덕후572 · ▲0

Having used both... SWR is great for simple cases, while React Query shines when things scale up. For a dashboard, starting with SWR and migrating later if needed is also a viable approach.

by 밤샘코더944 · ▲0

Both are good, but the recent trend seems to lean a bit more toward React Query? However, for a dashboard, you might not even need it—fetch + useState could be enough. Before adopting a library, make sure to first consider whether it's truly necessary.

by 코딩하는곰491 · ▲0