npm / swr
swr
What changed in swr 2, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-22.
2 new APIs and options6 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initswr 28 changes
New APIs and options 2
The experimental cacheData option enables preloading data in React Server Components and passing it to client hooks through SWRConfig, avoiding a duplicate initial browser request and hydrating the result into the SWR cache.
The new unload() API clears the entire SWR cache and discards in-flight requests and mutations. Mounted hooks revalidate by default, or pass { revalidate: false } to keep the cache empty until the next revalidation.
Fixes and other changes 6
Hooks without a fetcher now hydrate cacheData correctly.
Suspense cacheData is revalidated when a component remounts.
Completed subscription state is cleaned up.
Fixed the React Server export so it resolves correctly in the published package.
Double-unsubscribing no longer removes the wrong subscriber from the cache.
A resolved promise no longer suspends because of missing status.