SWR alternatives and similar libraries
Based on the "API" category.
Alternatively, view SWR alternatives based on common mentions on social networks and blogs.
-
React Query
DISCONTINUED. ๐ค Powerful asynchronous state management, server-state utilities and data fetching for TS/JS, React, Solid, Svelte and Vue. [Moved to: https://github.com/TanStack/query] -
urql
The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow. -
Optic
OpenAPI linting, diffing and testing. Optic helps prevent breaking changes, publish accurate documentation and improve the design of your APIs. -
SapphireDb
SapphireDb Server, a self-hosted, easy to use realtime database for Asp.Net Core and EF Core -
Hatchify
JavaScript, open source, CRUD app scaffolding that turns schemas into an app quickly, while allowing customization later. -
prim-rpc
Easy-to-understand, type-safe, transport-agnostic RPC/IPC for JavaScript, supporting callbacks, batching, file handling, custom serialization, and more. -
Bearer API Client for JavaScript
DISCONTINUED. Bearer provides all of the tools to build, run and manage API integrations.
CodeRabbit: AI Code Reviews for Developers

* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of SWR or a related project?
README
Introduction
SWR is a React Hooks library for data fetching.
The name โSWRโ is derived from stale-while-revalidate
, a cache invalidation strategy popularized by HTTP RFC 5861.
SWR first returns the data from cache (stale), then sends the request (revalidate), and finally comes with the up-to-date data again.
With just one hook, you can significantly simplify the data fetching logic in your project. And it also covered in all aspects of speed, correctness, and stability to help you build better experiences:
- Fast, lightweight and reusable data fetching
- Transport and protocol agnostic
- Built-in cache and request deduplication
- Real-time experience
- Revalidation on focus
- Revalidation on network recovery
- Polling
- Pagination and scroll position recovery
- SSR and SSG
- Local mutation (Optimistic UI)
- Built-in smart error retry
- TypeScript
- React Suspense
- React Native
...and a lot more.
With SWR, components will get a stream of data updates constantly and automatically. Thus, the UI will be always fast and reactive.
View full documentation and examples on swr.vercel.app.
Quick Start
import useSWR from 'swr'
function Profile() {
const { data, error } = useSWR('/api/user', fetcher)
if (error) return <div>failed to load</div>
if (!data) return <div>loading...</div>
return <div>hello {data.name}!</div>
}
In this example, the React Hook useSWR
accepts a key
and a fetcher
function.
The key
is a unique identifier of the request, normally the URL of the API. And the fetcher
accepts
key
as its parameter and returns the data asynchronously.
useSWR
also returns 2 values: data
and error
. When the request (fetcher) is not yet finished,
data
will be undefined
. And when we get a response, it sets data
and error
based on the result
of fetcher
and rerenders the component.
Note that fetcher
can be any asynchronous function, you can use your favourite data-fetching
library to handle that part.
View full documentation and examples on swr.vercel.app.
Authors
This library is created by the team behind Next.js, with contributions from our community:
- Shu Ding (@shuding_) โ Vercel
- Guillermo Rauch (@rauchg) โ Vercel
- Joe Haddad (@timer150) - Vercel
- Paco Coursey (@pacocoursey) - Vercel
Thanks to Ryan Chen for providing the awesome swr
npm package name!
License
The MIT License.
*Note that all licence references and agreements mentioned in the SWR README section above
are relevant to that project's source code only.