React Hooks library for data fetching.
The name “SWR” is derived from stale-while-revalidate, a HTTP cache invalidation strategy popularized by HTTP RFC 5861. SWR is a strategy to first return the data from cache (stale), then send the fetch request (revalidate), and finally come with the up-to-date data.
With SWR, components will get a stream of data updates constantly and automatically.
And the UI will be always fast and reactive.
Refer to official documentation for detailed usage. →
Pass an API key and start using it inside any function components:
fetcher is an async function that accepts the key of SWR, and returns the data. You can use any library to handle data fetching.
useSWR also returns a
mutate method that is pre-bound to SWR's key
mutate can also be imported directly form
If you didn't choose the plugin during project creation phase, you can follow the instructions below to add it.