UNPKG

next-pwa-pack

Version:

PWA cache provider for Next.js/React apps (service worker, manifest, offline page, SPA cache, offline)

2 lines 399 B
"use client"; import{useEffect}from"react";import{updatePageCache}from"./pwaActions";export default function SWRevalidateListener(){return useEffect((()=>{const e=e=>{if("swRevalidate"===e.key&&e.newValue)try{const{urls:t}=JSON.parse(e.newValue);Array.isArray(t)&&t.forEach(updatePageCache)}catch{}};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)}),[]),null}