feat: add service worker for PWA support (offline caching, installability)

- Add sw.js with stale-while-revalidate caching for static assets
- Network-first for HTML navigation, skip API/WS requests
- Register service worker in main.tsx on page load
- Enhanced manifest.json with orientation, categories, and all icon sizes
- App is now installable as a standalone PWA on mobile and desktop
This commit is contained in:
Nicolas Varrot
2026-02-13 05:11:39 +00:00
parent 33d72d65bd
commit 5a4c5ba457
3 changed files with 84 additions and 1 deletions

View File

@@ -5,6 +5,15 @@ import { ErrorBoundary } from './components/ErrorBoundary'
import { ThemeProvider } from './contexts/ThemeContext'
import './index.css'
// Register service worker for PWA support (offline caching, installability)
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js').catch(() => {
// SW registration failed — app works fine without it
});
});
}
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<ErrorBoundary>