Progress Web Apps (PWA's)
Build a Progressive Web App with Aurelia 2 using modern tooling and 2025 best practices. PWAs provide native-like experiences with offline functionality, push notifications, and app-like installation.
Installation
Install the Vite PWA plugin for zero-config PWA setup:
npm install -D vite-plugin-pwaVite Configuration
Update your vite.config.ts to include PWA capabilities:
// vite.config.ts
import { defineConfig } from 'vite';
import { VitePWA } from 'vite-plugin-pwa';
import aurelia from '@aurelia/vite-plugin';
export default defineConfig({
plugins: [
aurelia(),
VitePWA({
registerType: 'autoUpdate',
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
runtimeCaching: [
{
urlPattern: /^https:\/\/api\.yourapp\.com\/.*/i,
handler: 'NetworkFirst',
options: {
cacheName: 'api-cache',
networkTimeoutSeconds: 10,
cacheableResponse: {
statuses: [0, 200]
}
}
}
]
},
manifest: {
name: 'Aurelia PWA',
short_name: 'AureliaPWA',
description: 'My Aurelia Progressive Web App',
theme_color: '#ffffff',
background_color: '#ffffff',
display: 'standalone',
start_url: '/',
icons: [
{
src: '/icons/pwa-192x192.png',
sizes: '192x192',
type: 'image/png',
purpose: 'any'
},
{
src: '/icons/pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any'
},
{
src: '/icons/pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'maskable'
}
]
}
})
]
});Service Worker Integration
The Vite PWA plugin automatically handles service worker registration. To add update prompts in your Aurelia app:
Register the service in your app:
Update Component
Create a component to handle PWA updates:
Icon Setup
Create properly sized icons for your PWA. The plugin expects icons in /public/icons/:
Maskable Icons
Create maskable icons with proper safe zone padding. Use maskable.app to test your icons. The important content should be within a circular area with 40% radius from the center.
Development and Testing
Development Mode
Enable PWA features in development:
Testing Your PWA
Build for production:
Serve the built app:
Test PWA features:
Use Chrome DevTools → Lighthouse for PWA audit
Check Application tab for manifest and service worker
Test offline functionality by toggling network
Verify installation prompt appears
Advanced Caching Strategies
For custom caching needs, create a custom service worker:
Best Practices
HTTPS Required - PWAs only work over HTTPS (or localhost for development)
Responsive Design - Ensure your app works on all screen sizes
Performance - Optimize Core Web Vitals for app-like experience
Offline Fallbacks - Provide meaningful offline pages and functionality
Update Strategy - Choose between
autoUpdateandpromptbased on user experience needs
Your Aurelia 2 app is now a fully-featured PWA with modern caching strategies, update management, and native-like installation capabilities.
Last updated
Was this helpful?