# SWR

MIT\-licensed React data\-fetching library with shared caching, revalidation and mutation helpers\.

ID: Q901 · Revision: 949

Type: software · License: MIT[^license] · Status: active

Website: https://swr.vercel.app



SWR is an open\-source React library for data fetching and caching\. A component supplies a key and a fetcher, while SWR coordinates cached data and refresh behavior\. Mutation helpers support updating the interface around remote writes\. It supplies client data\-state machinery, not a backend or proof that an optimistic UI change has been saved\.[^start][^cache][^mutation]

## Capabilities and substitutions

### Fetcher\-independent data access — supported

Application supplies fetcher logic; REST, GraphQL or other clients can be integrated\.[^start]

Use case: Fetching, refreshing and mutating server\-backed data in React interfaces · Platforms: React applications · Region: Version, build and integration requirements apply

### Automatic refresh policies — supported

Focus and network reconnect revalidate by default; intervals and immutable behavior are configurable\.[^revalidation]

Use case: Fetching, refreshing and mutating server\-backed data in React interfaces · Platforms: React applications · Region: Version, build and integration requirements apply

### Custom cache providers — supported

Map\-like providers scope cache behavior to an SWRConfig boundary\.[^cache]

Use case: Fetching, refreshing and mutating server\-backed data in React interfaces · Platforms: React applications · Region: Version, build and integration requirements apply

### Optimistic UI and local rollback — supported

Mutation helpers can show optimistic data and restore prior local cache on failure; this is not a server transaction rollback\.[^mutation]

Use case: Fetching, refreshing and mutating server\-backed data in React interfaces · Platforms: React applications · Region: Version, build and integration requirements apply

### Unsuccessful HTTP response detection — limited

The fetcher must turn unsuccessful status codes into errors; parsed JSON alone does not establish success\.[^errors]

Use case: Fetching, refreshing and mutating server\-backed data in React interfaces · Platforms: React applications · Region: Version, build and integration requirements apply

### [Substitute for TanStack Query](/tanstackquery) — limited

Can replace TanStack Query for React data fetching, caching and supported mutation flows after rewriting hooks and policies\. Provider boundaries, key dependencies and refetch behavior must be explicitly migrated\.[^start][^cache][^mutation][^query]

Use case: Fetching, refreshing and mutating server\-backed data in React interfaces · Platforms: React applications · Region: Version, build and integration requirements apply

## References

[^license]: [SWR license](<https://github.com/vercel/swr/blob/main/LICENSE>) — MIT terms (vendor; retrieved 2026-10-07T23:14:37Z)

[^start]: [SWR getting started](<https://swr.vercel.app/docs/getting-started>) — React key/fetcher setup (vendor; retrieved 2026-10-07T23:13:58Z)

[^arguments]: [SWR arguments](<https://swr.vercel.app/docs/arguments>) — Entire key identity and changed fetcher context (vendor; retrieved 2026-10-07T23:15:20Z)

[^revalidation]: [SWR automatic revalidation](<https://swr.vercel.app/docs/revalidation>) — Focus/reconnect defaults, intervals and immutable resources (vendor; retrieved 2026-10-07T23:15:02Z)

[^errors]: [SWR error handling](<https://swr.vercel.app/docs/error-handling>) — Fetcher rejection, HTTP status checks and data/error coexistence (vendor; retrieved 2026-10-07T23:14:53Z)

[^cache]: [SWR cache providers](<https://swr.vercel.app/docs/advanced/cache>) — Provider boundaries and global mutate limitations (vendor; retrieved 2026-10-07T23:14:53Z)

[^mutation]: [SWR mutation and revalidation](<https://swr.vercel.app/docs/mutation>) — Mounted\-hook requirement, optimisticData, rollbackOnError and populateCache (vendor; retrieved 2026-10-07T23:15:02Z)

[^query]: [TanStack Query overview](<https://tanstack.com/query/latest/docs/framework/react/overview>) — Server\-state caching and query functions (vendor; retrieved 2026-10-07T23:13:58Z)

Source revision: https://substitutefor.net/entities/Q901?revision=949
