stremio/apps/admin-ui/src/components/PwaRegister.tsx
Jos Vooges | STH d53a4f9297 Make admin UI mobile-first with bottom nav and installable PWA support.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-29 02:11:40 +02:00

20 lines
611 B
TypeScript

"use client";
import { useEffect } from "react";
/** Registers the service worker for PWA install / offline shell. */
export function PwaRegister() {
useEffect(() => {
if (typeof window === "undefined" || !("serviceWorker" in navigator)) return;
const onLoad = () => {
navigator.serviceWorker.register("/sw.js").catch(() => {
/* ignore — private mode / insecure context */
});
};
if (document.readyState === "complete") onLoad();
else window.addEventListener("load", onLoad);
return () => window.removeEventListener("load", onLoad);
}, []);
return null;
}