Skip to content

About

Synchronize SWR cache with localStorage or sessionStorage to get offline cache

Topics

Resources

Code of conduct

Stars

110 stars

Watchers

1 watching

Forks

Latest commit

 

History

115 Commits

Folders and files

Repository files navigation

swr-sync-storage

CI Publish Maintainability Test Coverage

Synchronize SWR cache with localStorage or sessionStorage to get offline cache.

Usage

Install it

$ yarn add swr-sync-storage

Note: You will need to provide SWR v0.2.0-beta.0 or greater

import { syncWithStorage } from "swr-sync-storage";
syncWithStorage("local");
syncWithStorage("session");

You can also import to already bound versions of local or session storage.

import { syncWithLocalStorage } from "swr-sync-storage";
syncWithLocalStorage();
import { syncWithSessionStorage } from "swr-sync-storage";
syncWithSessionStorage();

Every function will return a new function to unsubscribe for cache changes.

About

Synchronize SWR cache with localStorage or sessionStorage to get offline cache

Topics

Resources

Code of conduct

Stars

110 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages