vercel/swr

React Hooks for Data Fetching

View on GitHub ↗Jump to charts ↓

Data as of . Signed-in members get hourly updates — create a free account.

Summary Information

Updated 55 minutes ago
Added to GitGenius on April 9th, 2022
Created on October 28th, 2019
Open Issues & Pull Requests: 232 (+0)
GitHub issues: Enabled
Number of forks: 1,395
Total Stargazers: 32,492 (+0)
Total Subscribers: 216 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 66.3 days
Mean response time: 330.6 days
90th percentile: 1149.3 days
Tracked items: 152

Maintainer activity

1 person did triage or write work on this repository in the last 12 months.

Counts unlabeled, assigned, unassigned, milestoned, demilestoned, locked, unlocked over the last 12 months. These are issue and pull request events that require triage or write permission. Commits and code review are not counted. labeled and renamed are excluded because GitHub issue forms record the issue author as the actor. Figures from October 7, 2026. This count is not comparable across projects: each project's automation decides which of these events a person emits.

How this project is maintained

95% of open issues come from outside the core team, so the backlog reflects real-world use rather than internal planning. Three people close 53% of everything that gets resolved.

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 115
New in 7 days: 0
Closed in 7 days: 0
Avg open age: 626 days
Stale 30+ days: 113
Stale 90+ days: 106

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

  • bug (42)
  • feature request (17)
  • reproduction needed (16)
  • discussion (15)
  • question (14)
  • area: typing (13)
  • good first issue (12)
  • area: mutation (10)

Most active issues this week

Sign in to see which issues are moving.
Sign in

Detailed Description

SWR is a React Hooks library for data fetching developed by the team behind Next.js at Vercel. The name derives from the stale-while-revalidate cache invalidation strategy defined in HTTP RFC 5861, which describes an approach where cached data is returned immediately while a revalidation request occurs in the background, ultimately providing updated data once available. This strategy enables applications to prioritize responsiveness by serving stale data instantly rather than waiting for fresh data from the network.

The library centers on a single primary hook called useSWR, which accepts a key (typically a URL) and a fetcher function as parameters. The fetcher is an asynchronous function responsible for retrieving data, and the hook returns three values: data, isLoading, and error. During the initial fetch, data remains undefined while isLoading is true. Once the request completes, the hook updates these values and triggers a component rerender. The fetcher function is transport and protocol agnostic, allowing developers to use any asynchronous data-fetching approach they prefer.

SWR provides extensive built-in functionality beyond basic data fetching. The library includes automatic request deduplication and caching mechanisms to reduce redundant network calls. It supports revalidation on focus and network recovery, enabling applications to refresh data when users return to the browser tab or regain connectivity. Additional features include polling for continuous updates, pagination support with scroll position recovery, server-side rendering and static site generation compatibility, local mutation for optimistic UI updates, and intelligent error retry logic. The library also supports React Suspense for declarative data loading states and works with React Native for mobile applications.

Written in TypeScript, SWR emphasizes performance and stability. The library is designed to be fast and lightweight while enabling components to receive continuous data updates automatically, resulting in UIs that remain responsive and reactive. The project is distributed under the MIT License and maintains comprehensive documentation at swr.vercel.app, which includes examples and detailed API references for developers implementing the library in their projects.