Progressive Web Apps with HTML
Build app-like web experiences with service workers, web app manifests, push notifications, and offline functionality using modern HTML5 APIs.
What is a Progressive Web App (PWA)?
A PWA is a website that can be installed and behave like an app: it opens in its own window, works offline and can send push notifications. It needs three things: HTTPS, a web app manifest (name, icons, colours, display: standalone), and a Service Worker that caches files so the app loads without a network.
<link rel="manifest" href="/manifest.webmanifest">
// manifest.webmanifest
{ "name": "Compileum", "short_name": "Compileum", "start_url": "/",
"display": "standalone", "theme_color": "#3b82f6",
"icons": [{ "src": "/icon-192.png", "sizes": "192x192", "type": "image/png" },
{ "src": "/icon-512.png", "sizes": "512x512", "type": "image/png" }] }
// register the service worker
navigator.serviceWorker?.register("/sw.js");PWA Features
Offline Support
Service worker caching
Push Notifications
Re-engagement messaging
App Shell
Instant loading architecture
Web Manifest
Native app installation
Complete PWA Implementation
Build a complete Progressive Web App with offline functionality, push notifications, device integration, and native app-like features.
Code Editor
<!-- 1. Manifest link (in <head>) -->
<link rel="manifest" href="/manifest.webmanifest">
<pre>// 2. manifest.webmanifest
{
"name": "Compileum",
"start_url": "/",
"display": "standalone",
"theme_color": "#2563eb",
"icons": [{ "src": "/icon-512.png", "sizes": "512x512", "type": "image/png" }]
}</pre>
<ul id="checks"></ul>Preview
Web App Manifest
Define your PWA's appearance, behavior, and installation experience with a comprehensive web app manifest file.
Manifest Properties:
- name & short_name: App display names
- icons: Multiple sizes for different contexts
- start_url: Launch URL when opened
- display: Presentation mode (standalone, fullscreen)
- theme_color: Browser UI theming
Service Workers
Implement service workers for offline functionality, background sync, push notifications, and advanced caching strategies.
Service Worker Features:
- Caching: Cache First, Network First, Stale While Revalidate
- Background Sync: Queue requests when offline
- Push Notifications: Server-sent notifications
- Update Management: Seamless app updates
Offline Functionality
Create robust offline experiences with smart caching, data synchronization, and graceful degradation patterns.
Offline Strategies:
- App Shell: Core UI cached for instant loading
- Dynamic Caching: Cache content as users navigate
- Fallback Pages: Custom offline experiences
- Background Sync: Sync data when connectivity returns
Push Notifications
Implement push notifications to re-engage users with timely, relevant, and personalized messages even when the app is closed.
Notification Components:
- Permission Request: User consent for notifications
- Subscription Management: Push endpoint registration
- Message Handling: Display and interaction logic
- VAPID Keys: Secure server identification
Device Integration
Access native device capabilities including camera, geolocation, sensors, and share functionality for rich user experiences.
Device APIs:
- MediaDevices: Camera and microphone access
- Geolocation: GPS and location services
- Web Share: Native sharing capabilities
- Device Sensors: Accelerometer, gyroscope data
Installation Experience
Create seamless installation prompts and optimize the add-to-homescreen experience across different platforms.
Installation Features:
- beforeinstallprompt: Custom install prompts
- Installation Criteria: PWA installability requirements
- Platform Integration: iOS, Android, Desktop support
- Update Notifications: App version management
Performance & Optimization
Optimize PWA performance with efficient loading strategies, resource management, and progressive enhancement techniques.
Optimization Strategies:
- Code Splitting: Load features on demand
- Resource Prioritization: Critical resource loading
- Memory Management: Efficient cache management
- Progressive Enhancement: Core functionality first
Progressive Web Apps — step by step
Create a Web App Manifest
A manifest.json (or manifest.webmanifest) file defines your app's name, icons, start URL, display mode, and theme color. Link it in your HTML with a link rel='manifest' tag. This enables the 'Add to Home Screen' prompt.
🎯 Quick Check
What file is required to make a web app installable as a PWA?
Progressive Web Apps: summary
Key points
- Lighthouse's PWA checks and the Application panel in DevTools show what's missing.
- Libraries like Workbox simplify writing caching strategies for Service Workers.
- PWAs can be listed in app stores using wrappers such as Trusted Web Activity on Android.
Frequently asked questions
›Do PWAs work on iPhone?
Yes. Users can add them to the home screen from Safari's Share menu, and recent iOS versions support web push for installed PWAs.