mirror of
https://github.com/KuekHaoYang/KVideo.git
synced 2026-08-14 16:23:43 +08:00
23 lines
661 B
TypeScript
23 lines
661 B
TypeScript
'use client';
|
|
|
|
import { useEffect } from 'react';
|
|
|
|
export function ServiceWorkerRegister() {
|
|
useEffect(() => {
|
|
if ('serviceWorker' in navigator) {
|
|
window.addEventListener('load', () => {
|
|
navigator.serviceWorker.register('/sw.js').then(
|
|
(registration) => {
|
|
console.log('ServiceWorker registration successful with scope: ', registration.scope);
|
|
},
|
|
(err) => {
|
|
console.log('ServiceWorker registration failed: ', err);
|
|
}
|
|
);
|
|
});
|
|
}
|
|
}, []);
|
|
|
|
return null;
|
|
}
|