How SpaceZero implements Progressive Web App features with vite-plugin-pwa: precached app shell, auto-updating service worker, and a generated web manifest.
SpaceZero includes PWA support via vite-plugin-pwa (which wraps Workbox under the hood).
registerType: 'autoUpdate' — new service workers activate automaticallypublic/manifest.json)// vite.config.ts
VitePWA({
registerType: 'autoUpdate',
includeAssets: ['favicon.ico'],
manifest: {
name: process.env.VITE_APP_NAME || 'SpaceZero',
short_name: process.env.VITE_APP_NAME || 'SpaceZero',
description: process.env.VITE_APP_DESCRIPTION || '...',
theme_color: '#121212',
background_color: '#121212',
display: 'standalone',
icons: [
{ src: 'favicon.ico', sizes: '48x48 72x72 96x96 128x128', type: 'image/x-icon' },
],
},
})
There is no custom `runtimeCaching`: the default Workbox generateSW strategy precaches the build output. If your app needs runtime caching (e.g. for API responses), add a workbox.runtimeCaching array here — SpaceZero does not ship one.
SpaceZero does not listen for beforeinstallprompt or render a custom install banner. Install UX is left to the browser (menu → "Install app"), which keeps the template free of platform-specific prompt logic.
Registered in index.html:
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js');
}
</script>
npm run build && npm run preview