Progressive Web App (PWA)
Crax supports PWA configuration with automatic icon generation and manifest creation.
Enable PWA
Add pwa config to crax.config.mjs:
Generate Icons
Place a logo.png (at least 512x512px) in your public/ directory, then run:
The script generates multiple icon sizes, a manifest.webmanifest, and patches index.html with icon links.
Auto-Injection
When pwa.enabled is true, the router automatically injects:
No manual HTML edits needed.
Configuration Options
Service Worker
Crax generates the manifest and icons only. For offline support or push notifications, add vite-plugin-pwa:
Push Notifications
Add push notifications using the Web Push API with web-push:
1. Generate VAPID Keys
Save to .env:
2. Create Service Worker
Create public/sw.js:
3. Client-Side Subscription
4. Server-Side Sending
Browser Support
- Chrome 42+
- Firefox 44+
- Edge 17+
- Safari 16+ (macOS Ventura+)
