mirror of
https://github.com/KuekHaoYang/KVideo.git
synced 2026-08-20 11:13:43 +08:00
22 lines
557 B
TypeScript
22 lines
557 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) => {
|
|
// Registration successful
|
|
})
|
|
.catch((err) => {
|
|
// Registration failed
|
|
});
|
|
});
|
|
}
|
|
}, []);
|
|
|
|
return null;
|
|
}
|