error retry interval in milliseconds
Optional
errormax error retry count
timeout to trigger the onLoadingSlow event in milliseconds
only revalidate once during a time span in milliseconds
dedupe requests with the same key in this time span in milliseconds
Optional
refreshhttps://swr.vercel.app/docs/revalidation
refreshInterval = 0
Optional
refreshpolling when the window is invisible (if refreshInterval
is enabled)
Optional
refreshpolling when the browser is offline (determined by navigator.onLine
)
automatically revalidate when window gets focused
automatically revalidate when the browser regains a network connection (via navigator.onLine
)
Optional
revalidateenable or disable automatic revalidation when component is mounted
automatically revalidate even if there is stale data
retry when fetcher has an error
Optional
keepkeep the previous result when key is changed but data is not ready
Optional
Experimental
suspenseenable React Suspense mode
Optional
fallbackinitial data to be returned (note: This is per-hook)
Optional
fetcherthe fetcher function
Optional
usearray of middleware functions
a key-value object of multiple fallback data
function to detect whether pause revalidations, will ignore fetched data and errors when it returns true. Returns false by default.
callback function when a request takes too long to load (see loadingTimeout
)
callback function when a request finishes successfully
callback function when a request returns an error
handler for error retry
callback function when a request is ignored
comparison function used to detect when returned data has changed, to avoid spurious rerenders. By default, stable-hash is used.
isOnline and isVisible are functions that return a boolean, to determine if the application is "active". By default, SWR will bail out a revalidation if these conditions are not met.
isOnline and isVisible are functions that return a boolean, to determine if the application is "active". By default, SWR will bail out a revalidation if these conditions are not met.
Link
https://swr.vercel.app/docs/options