# SWR

[BASE product page](<https://base.akulich.dev/en/library/swr/>) · [Resource](<https://github.com/vercel/swr>)

ID: swr · Language: en
Schema version: 1 · Data version: cbbe7123b47a5ae80983

This is editorial data. An unknown field neither confirms nor rules out a capability.
dataVersion is a dataset fingerprint, not evidence of a recent fact check.

React data fetching hooks with caching and revalidation: they display current server data and request states in the interface\.

## Type

Web framework / library

## Entry type

library

## Separate catalog

No

## [Access conditions](<https://base.akulich.dev/en/library/swr/#resource-access>)

free

## [What you can use for free](<https://base.akulich.dev/en/library/swr/#resource-access>)

Code and local use under MIT\.

## [Paid features and costs](<https://base.akulich.dev/en/library/swr/#resource-access>)

Computing resources, self\-hosting, and external services are paid for separately if used\.

## [Access and limitations](<https://base.akulich.dev/en/library/swr/#resource-access>)

Code and local use under MIT\. Computing resources, self\-hosting, and external services are paid for separately if used\.

## [Use cases](<https://base.akulich.dev/en/library/swr/#resource-tasks>)

- Add cached data fetching to a React screen
- Connect the hook to the component's loading, error, and revalidation states

## Category IDs

- frontend

## Subcategory IDs

- frontend\.utilities
- frontend\.state

## Tags

- SWR
- web
- Development

## Also known as

- vercel/swr
- swr
- stale\-while\-revalidate

## [Selection purpose](<https://base.akulich.dev/en/library/swr/#resource-selection>)

Add cached data fetching to a React screen

## [Choose this when](<https://base.akulich.dev/en/library/swr/#resource-selection>)

- Add cached data fetching to a React screen
- Connect the hook to the component's loading, error, and revalidation states

## [Consider alternatives when](<https://base.akulich.dev/en/library/swr/#resource-selection>)

- When choosing for this topic, compare SWR with TanStack Query\. A candidate to compare under the topic: State and client data, Web interface tools\. This is an editorial connection by topic, not a confirmed alternative or a guarantee that the products work together\.
- When choosing for this topic, compare SWR with Immer\. A candidate to compare under the topic: State and client data\. This is an editorial connection by topic, not a confirmed alternative or a guarantee that the products work together\.

## [Requirements](<https://base.akulich.dev/en/library/swr/#resource-selection>)

- Define stable keys, a fetcher, and separate loading/error states\.

## [Limitations](<https://base.akulich.dev/en/library/swr/#resource-selection>)

- Costs and limits of free use: Computing resources, self\-hosting, and external services are paid for separately if used\.
- Terms of use: MIT for the code; dependencies have separate licenses\.
- A cache does not replace server permissions or important data freshness checks\. The fetcher may use a chosen network/API and its terms\.

## [Questions before use](<https://base.akulich.dev/en/library/swr/#resource-faq>)

### What can you use for free in SWR?

Code and local use under MIT\.

### What additional costs might arise with SWR?

Computing resources, self\-hosting, and external services are paid for separately if used\.

### What terms of use matter for SWR?

MIT for the code; dependencies have separate licenses\.

### How do you get started with SWR?

Define a data key and fetcher for the required API\. Connect the hook to the component's loading, error, and revalidation states\. Add real data and error handling; check the production build\.

### What does SWR do with stale data, and what is a fetcher?

SWR first returns cached data, then revalidates the request and updates the result\. useSWR accepts a key and asynchronous fetcher, returning data, error, and isLoading\. Deduplication, focus/network recovery revalidation, polling, optimistic mutation, and SSR/SSG are supported; the fetcher chooses the transport\.

## Related resources selected by editors

- tanstack\-query: A candidate to compare under the topic: State and client data, Web interface tools\. This is an editorial connection by topic, not a confirmed alternative or a guarantee that the products work together\.
- immer: A candidate to compare under the topic: State and client data\. This is an editorial connection by topic, not a confirmed alternative or a guarantee that the products work together\.
- jotai: A candidate to compare under the topic: State and client data\. This is an editorial connection by topic, not a confirmed alternative or a guarantee that the products work together\.

## Sources for the selection guide

- [https://github\.com/vercel/swr](<https://github.com/vercel/swr>)
- [https://raw\.githubusercontent\.com/vercel/swr/HEAD/README\.md](<https://raw.githubusercontent.com/vercel/swr/HEAD/README.md>)
- [https://raw\.githubusercontent\.com/vercel/swr/HEAD/LICENSE](<https://raw.githubusercontent.com/vercel/swr/HEAD/LICENSE>)
- [https://www\.open\-source\-tools\.com/](<https://www.open-source-tools.com/>)

## [Possible workflow](<https://base.akulich.dev/en/library/swr/#resource-scenario>)

Add cached data fetching to a React screen\.

A possible workflow; this is not a report of hands-on testing.

## Before you start

- Web application source code and the intended workflow\.
- The project's framework and runtime version\.

## Steps

1. Define a data key and fetcher for the required API\.
2. Connect the hook to the component's loading, error, and revalidation states\.
3. Add real data and error handling; check the production build\.

## Check your result

- The workflow works after a page refresh and with invalid data\.
- The bundle, server rendering, and supported browsers suit the project\.

## [License](<https://base.akulich.dev/en/library/swr/#resource-license>)

MIT for the code; dependencies have separate licenses\.

## License explanations for the specified scope

### MIT — permissive license

You can use, modify, distribute, and sell the code, including in a closed\-source commercial product\. When sharing copies or substantial portions of the code, retain the license text and copyright notice\. You do not need to open\-source your entire project; the author provides no warranties\.

[License terms](<https://opensource.org/license/mit>)

## Related resource IDs

- zustand
- jotai
- valtio
- immer
- tanstack\-query

## [Sources](<https://base.akulich.dev/en/library/swr/#resource-sources>)

- [Official source](<https://github.com/vercel/swr>)
- [Official source](<https://raw.githubusercontent.com/vercel/swr/HEAD/README.md>)
- [License](<https://raw.githubusercontent.com/vercel/swr/HEAD/LICENSE>)
- [Catalog / discovery source](<https://www.open-source-tools.com/>)

## Editorial review date

2026\-10\-06

## Editorial review scope

The purpose, current repository license, and separate terms for code, services, and models have been reviewed\. The product was not run, and no security audit was performed\.

Dates refer to the stated editorial review, not hands-on testing, a product update, or a recent review of all sources.
