swr-sync-storage

JSON →
library 1.0.1 ·javascript
verified Jun 7, 2026

Synchronize SWR cache with localStorage or sessionStorage to provide offline cache persistence. Version 1.0.1, stable release. Requires SWR v0.2.0-beta.0 or greater as a peer dependency. This package allows binding SWR's cache to browser storage (localStorage or sessionStorage), enabling offline support and cache persistence across sessions. It provides three importable functions: syncWithStorage (generic, takes a storage type string), syncWithLocalStorage (pre-bound to localStorage), and syncWithSessionStorage (pre-bound to sessionStorage). Unlike manual cache management, it automatically syncs SWR cache changes to storage and restores cache on reload. Supports custom JSON parsing for non-object values. TypeScript types included.