This project is now a fully functional Progressive Web App (PWA) with the following features:
- 📱 Installable: Users can install the app on their devices (mobile and desktop)
- 🔄 Offline Support: The app works offline with intelligent caching strategies
- ⚡ Fast Loading: Optimized caching for faster subsequent loads
- 📲 App-like Experience: Runs in standalone mode without browser UI
- 🎨 Adaptive Icons: Theme-aware icons for light and dark modes
- @ducanh2912/next-pwa - Next.js 15+ compatible PWA plugin
public/manifest.json- PWA manifest configurationpublic/offline.html- Beautiful offline fallback pagecomponents/pwa-install-prompt.tsx- Install prompt componentnext.config.mjs- PWA configuration with caching strategiesapp/layout.tsx- Added PWA meta tags and manifest link
- CacheFirst: For fonts and media files that rarely change
- StaleWhileRevalidate: For images, CSS, JS - serve cached version while updating
- NetworkFirst: For API calls and dynamic content - try network first, fallback to cache
The PWA is automatically configured. When users visit the site:
- On supported browsers, an install prompt will appear
- Users can also install via browser menu (Chrome: "Install App", Safari: "Add to Home Screen")
- The app icon will appear on their device home screen
# Development mode (PWA disabled)
pnpm dev
# Production build (PWA enabled) - uses webpack
pnpm build
# Start production server
pnpm startNote: The build uses webpack instead of Turbopack for PWA compatibility with Next.js 16.
The following files are auto-generated and should not be committed (already in .gitignore):
public/swe-worker-*.js- Service worker entrypublic/workbox-*.js- Workbox runtime filespublic/sw.js.map- Source maps (if generated)
- Build the production version:
pnpm build - Start the server:
pnpm start - Open Chrome DevTools → Application → Manifest
- Check the "Service Workers" section
- Use Lighthouse to audit PWA score
- ✅ Chrome/Edge (Android/Desktop)
- ✅ Safari (iOS/macOS) - with "Add to Home Screen"
- ✅ Firefox (Android/Desktop)
- ✅ Samsung Internet
PWA features require HTTPS in production. Local development works on localhost without HTTPS.
The app uses adaptive icons:
- Light mode:
/icon-light-32x32.png - Dark mode:
/icon-dark-32x32.png - Apple Touch:
/apple-icon.png - Logo:
/placeholder-logo.png
For best results, provide icons in these sizes:
- 32x32, 72x72, 96x96, 128x128, 144x144, 152x152, 192x192, 384x384, 512x512
- Open Chrome DevTools
- Go to Network tab
- Select "Offline" from throttling dropdown
- Reload the page
- You should see the offline fallback page
- First Load: ~2-3s (depends on connection)
- Subsequent Loads: <1s (from cache)
- Offline: Instant (from cache)
The service worker automatically updates when you deploy new versions. Users will get the update on their next visit after the old service worker expires.
If PWA features aren't working:
- Check HTTPS is enabled (required for production)
- Clear browser cache and service workers
- Rebuild the app:
pnpm build - Check browser console for errors
- Verify manifest.json is accessible at
/manifest.json