Gathering detailed insights and metrics for swr
Gathering detailed insights and metrics for swr
Gathering detailed insights and metrics for swr
Gathering detailed insights and metrics for swr
npm install swr
Typescript
Module System
Node Version
NPM Version
97.2
Supply Chain
100
Quality
91.8
Maintenance
100
Vulnerability
100
License
TypeScript (99.23%)
JavaScript (0.75%)
Shell (0.02%)
Total Downloads
306,944,096
Last Day
211,903
Last Week
3,725,940
Last Month
15,654,624
Last Year
138,524,631
MIT License
31,633 Stars
912 Commits
1,273 Forks
218 Watchers
18 Branches
259 Contributors
Updated on Jul 03, 2025
Minified
Minified + Gzipped
Latest Version
2.3.4
Package Id
swr@2.3.4
Unpacked Size
260.14 kB
Size
54.25 kB
File Count
53
NPM Version
10.8.2
Node Version
20.19.2
Published on
Jul 02, 2025
Cumulative downloads
Total Downloads
Last Day
-6.6%
211,903
Compared to previous day
Last Week
-7.5%
3,725,940
Compared to previous week
Last Month
7.8%
15,654,624
Compared to previous month
Last Year
71.7%
138,524,631
Compared to previous year
2
1
34
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:
...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.
1import useSWR from 'swr' 2 3function Profile() { 4 const { data, error, isLoading } = useSWR('/api/user', fetcher) 5 6 if (error) return <div>failed to load</div> 7 if (isLoading) return <div>loading...</div> 8 return <div>hello {data.name}!</div> 9}
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 3 values: data
, isLoading
and error
. When the request (fetcher) is not yet finished,
data
will be undefined
and isLoading
will be true
. When we get a response, it sets data
and error
based on the result
of fetcher
, isLoading
to false 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.
This library is created by the team behind Next.js, with contributions from our community:
Thanks to Ryan Chen for providing the awesome swr
npm package name!
The MIT License.
No vulnerabilities found.
Reason
security policy file detected
Details
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 20/30 approved changesets -- score normalized to 6
Reason
3 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 3
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
10 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More@orval/swr
[](https://badge.fury.io/js/orval) [](https://opensource.org/licenses/MIT) [![tests](https://github.com/orval-labs/orval/actions/workflow
swr-store
SWR stores for data-fetching
vue-request
This is a library that can easily help you manage request states, supporting common features such as SWR, polling, error retry, caching, and pagination, etc.
@kubb/plugin-swr
Generator plugin-swr