-
Service Worker (
frontend/public/sw.js)- Caches static assets and API responses
- Implements network-first strategy for API calls
- Cache-first strategy for static assets
- Background sync for failed requests
- Push notification handlers
-
Web App Manifest (
frontend/public/manifest.json)- App metadata and branding
- Icon definitions for all sizes
- Display mode and theme colors
- App shortcuts for quick access
-
PWA Utilities (
frontend/lib/pwa.js)- Service worker registration
- Push notification subscription management
- Background sync triggers
- Online/offline status monitoring
-
Offline Storage (
frontend/lib/offlineStorage.js)- IndexedDB wrapper for offline data caching
- API response caching for offline access
-
Network Status Banner (
frontend/components/NetworkStatus.js)- Shows online/offline status
- Auto-dismisses when back online
-
PWA Install Prompt (
frontend/components/PWAInstallPrompt.js)- Prompts users to install the app
- Handles beforeinstallprompt event
-
Offline Page (
frontend/pages/offline.js)- Fallback page when offline
- Retry button to check connection
-
usePWA Hook (
frontend/hooks/usePWA.js)- React hook for PWA features
- Manages notifications and sync
-
Updated _app.js
- Registers service worker on load
- Includes NetworkStatus and PWAInstallPrompt
-
Updated _document.js
- PWA meta tags
- Manifest link
- Apple touch icons
-
Updated api.js
- Offline-aware API client
- Auto-caches GET requests
- Queues failed requests for sync
-
Notifications API (
backend/routes/notifications.js)- Subscribe/unsubscribe endpoints
- Send push notifications
- VAPID authentication
-
Updated Settings Page
- PWA controls
- Enable/disable notifications
- Connection status display
-
Install Dependencies
cd novaRewards/backend npm install -
Generate VAPID Keys
npx web-push generate-vapid-keys
-
Update .env File Add the generated keys to your
.envfile (see.env.example) -
Create App Icons Place icons in
frontend/public/icons/(seescripts/generate-pwa-icons.md) -
Build and Test
cd novaRewards/frontend npm run build npm start
- Service worker registers successfully
- App works offline (cached pages load)
- Install prompt appears on supported browsers
- Push notifications can be enabled/disabled
- Network status banner shows when offline/online
- Background sync queues failed requests
- Manifest loads correctly (check DevTools > Application)
- Generate and add app icons
- Configure VAPID keys in environment
- Test on mobile devices
- Consider adding to app stores (TWA for Android)
- Monitor PWA metrics and user adoption