Vanilla SWR
stale-while-revalidate
caching strategy for vanilla web-apps

Installation
npm
npm install vanilla-swr
OR
yarn
yarn add vanilla-swr
OR
Import it from a CDN
jsDelivr
<script src="https://cdn.jsdelivr.net/npm/vanilla-swr/dist/index.min.js"></script>
unpkg
<script src="https://unpkg.com/vanilla-swr/dist/index.js"></script>
SWR
variable is present in the window object.
Quick Start
import SWR from "vanilla-swr";
const fetcher = (...args) => fetch(...args).then((res) => res.json());
const observable = SWR("/api/data", fetcher);
const watcher = observable.watch(({ data, error }) => {
});
watcher.unwatch();
Documentation
https://vanilla-swr.js.org/
License
MIT