PWA
4 Nov 2026
8 min read

PWA Offline Support: Service Workers and the App Manifest

How SpaceZero implements Progressive Web App features with vite-plugin-pwa: precached app shell, auto-updating service worker, and a generated web manifest.

PWA Offline Support

SpaceZero includes PWA support via vite-plugin-pwa (which wraps Workbox under the hood).

Features

  • App Shell Precaching: Built assets are precached by the generated service worker
  • Auto Updates: registerType: 'autoUpdate' — new service workers activate automatically
  • Web Manifest: Generated at build time from the plugin config (no public/manifest.json)
  • Installable: Ships a manifest and icons, so Chrome/Edge offer native install

Configuration

typescript

// 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.

No Custom Install Prompt

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.

Service Worker Registration

Registered in index.html:

html

<script>

if ('serviceWorker' in navigator) {

navigator.serviceWorker.register('/sw.js');

}

</script>

Testing

  1. Run npm run build && npm run preview
  2. Open DevTools → Application → Service Workers
  3. Check "Offline" → refresh
  4. Verify the app shell loads from cache
  5. DevTools → Application → Manifest to inspect the generated manifest

Benefits

  • Reliability: App shell works offline or on flaky connections
  • Native Feel: Standalone display mode when installed
  • Performance: Precached assets load instantly
  • Zero Config: Sensible defaults, easy to extend with runtime caching