'use client'; import { useEffect } from 'react'; /** * Registers the service worker once, from the app shell. * * The URL is built with `import.meta.url` so the bundler emits the worker and gives it a * stable path; `updateViaCache: 'none'` means a deploy is picked up on the next visit * rather than whenever the browser feels like re-checking. */ export function PwaProvider() { useEffect(() => { if (!('serviceWorker' in navigator)) return; void navigator.serviceWorker .register(new URL('../lib/service-worker.js', import.meta.url), { scope: '/', updateViaCache: 'none', }) // A browser that refuses to register one (private mode, an unsupported context) is // not an error the reader can do anything about. .catch(() => undefined); }, []); return null; }