feat: convert app to PWA with offline support and service worker

This commit is contained in:
2026-02-26 18:01:33 +01:00
parent 1d72f34b65
commit f20cedffd5
5 changed files with 129 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
'use client';
import { useEffect } from 'react';
export function SWRegistration() {
useEffect(() => {
if ('serviceWorker' in navigator && process.env.NODE_ENV === 'production') {
window.addEventListener('load', () => {
navigator.serviceWorker
.register('/sw.js')
.then((registration) => {
console.log('SW registered:', registration);
})
.catch((error) => {
console.log('SW registration failed:', error);
});
});
}
}, []);
return null;
}