feat: build production-ready wtr weather PWA
This commit is contained in:
12
components/layout/service-worker-register.tsx
Normal file
12
components/layout/service-worker-register.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
|
||||
export function ServiceWorkerRegister() {
|
||||
useEffect(() => {
|
||||
if ("serviceWorker" in navigator && process.env.NODE_ENV === "production") {
|
||||
navigator.serviceWorker.register("/sw.js").catch(() => undefined);
|
||||
}
|
||||
}, []);
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user