DEV Community

Discussion on: React Query vs useSWR

Collapse
 
brense profile image
Rense Bakker

SWR most certainly does provide pagination: swr.vercel.app/docs/pagination

React Query has a more robust and feature-rich API

This is highly subjective... While it's true that SWR is still in beta, it does offer an extensive API and off the top of my head I cannot think of anything that it's missing compared to React Query... Also React Query doesn't support ISR. It depends on what you're looking for really.

I'm also not sure about your claims on performance... SWR definitely seems much more agressive about caching, prefering stale data over refetching...

Collapse
 
sakethkowtha profile image
sakethk

SWR will not cancel processing tasks while react-query will do that on these aspect react-query is bit ahead.

Collapse
 
brense profile image
Rense Bakker

From React Query documentation:

By default, queries that unmount or become unused before their promises are resolved are not cancelled.

Both React Query and SWR work with providing your own fetcher. Cancelling requests depends on what fetcher you use...

// Example abort with fetch:
const controller = new AbortController()
fetch('https://google.com', { signal: controller.signal }))
controller.abort()

// Example abort with axios
const source = axios.CancelToken.source()
axios.get('https://google.com', { cancelToken: source.token })
source.cancel()
Enter fullscreen mode Exit fullscreen mode