npx nuxi@latest module add @vite-pwa/nuxt
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@vite-pwa/nuxt'],
pwa: {
registerType: 'prompt',
manifest: {
id: '/', name: 'My Nuxt App', short_name: 'Nuxt App', theme_color: '#5A0FC8',
icons: [
{ src: 'pwa-192x192.png', sizes: '192x192', type: 'image/png' },
{ src: 'pwa-512x512.png', sizes: '512x512', type: 'image/png' },
{ src: 'maskable-512x512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' },
],
},
workbox: { navigateFallback: '/' },
client: { installPrompt: true },
},
});
Add <NuxtPwaManifest /> to app.vue. The $pwa helper exposes needRefresh, updateServiceWorker(), offlineReady and, with installPrompt, showInstallPrompt and install():
<template>
<div v-if="$pwa?.needRefresh">
New version available. <button @click="$pwa.updateServiceWorker()">Reload</button>
</div>
</template>
For server-rendered routes, navigateFallback only helps pages you prerender; use a runtime NetworkFirst rule for others. Options are the same as vite-plugin-pwa.