Download src/components/service-worker-register.tsx from NAP1320/RotNot: direct link, hf CLI and curl.
- Browser
- Download file 739 Bytes
-
https://huggingface.co/spaces/NAP1320/RotNot/resolve/main/src/components/service-worker-register.tsx
- Command line
-
hf download hf://spaces/NAP1320/RotNot/src/components/service-worker-register.tsx
-
curl -L -o service-worker-register.tsx https://huggingface.co/spaces/NAP1320/RotNot/resolve/main/src/components/service-worker-register.tsx
739 Bytes
| "use client"; | |
| import { useEffect } from "react"; | |
| export function ServiceWorkerRegister() { | |
| useEffect(() => { | |
| if ( | |
| typeof window !== "undefined" && | |
| "serviceWorker" in navigator && | |
| process.env.NODE_ENV === "production" | |
| ) { | |
| navigator.serviceWorker | |
| .register("/service-worker.js", { scope: "/" }) | |
| .then((registration) => { | |
| console.log("[SW] Registered:", registration.scope); | |
| // Check for updates periodically (every 60 minutes) | |
| setInterval(() => { | |
| registration.update(); | |
| }, 60 * 60 * 1000); | |
| }) | |
| .catch((error) => { | |
| console.error("[SW] Registration failed:", error); | |
| }); | |
| } | |
| }, []); | |
| return null; | |
| } | |