Skip to content
vite-pwaPublic

About

Zero-config PWA Plugin for Nuxt 3

Topics

Resources

Code of conduct

Contributing

Stars

582 stars

Watchers

4 watching

Forks

Repository files navigation

@vite-pwa/nuxt - Nuxt PWA Ecosystem logo

Nuxt PWA Ecosystem

Docs & Guides
GitHub stars


Anthony Fu SVG sponsors image

🚀 Features

  • 📖 Documentation & guides
  • 👌 Zero-Config: sensible built-in default configs for common use cases
  • 🔩 Extensible: expose the full ability to customize the behavior of the plugin
  • 🦾 Type Strong: written in TypeScript
  • 🔌 Offline Support: generate service worker with offline support (via Workbox)
  • ⚡ Fully tree shakable: client virtual modules are strictly optimized for Dead Code Elimination.
  • 📄 Web Manifest: auto-inject Web App Manifest and PWA assets seamlessly.
  • 💬 Prompt for new content: built-in support for Vanilla JavaScript, Vue 3, React, Svelte, SolidJS and Preact
  • ⚙️ Stale-while-revalidate: automatic reload when new content is available
  • ✨ Static assets handling: configure static assets for offline support
  • 🐞 Development Support: debug your custom service worker logic as you develop your application
  • 🔍 Inspector: visually inspect your resolved configuration, web manifest and service worker during development, via middleware or DevFrame
  • 🧩 Modular: use the ready-to-use plugins or compose your own integration from the building blocks in @unplugin-pwa/core and @unplugin-pwa/vite
  • 📦 Universal Bundlers: native integration with Vite, Rolldown, Webpack (WIP), Rspack (WIP), and Rsbuild (WIP).
  • 🛠️ Meta-Frameworks: seamless integration with îles, SvelteKit, VitePress, Astro, Nuxt 3/4/5, React Router, TanStack and Next (WIP).
  • 💥 PWA Assets Generator: generate all the PWA assets from a single command and a single source image
  • 🚀 PWA Assets Integration: serving, generating and injecting PWA Assets on the fly in your application

📦 Install

@vite-pwa/nuxt requires Nuxt 3.9.0+ with the Vite builder.

npx nuxt module add @vite-pwa/nuxt

🦄 Usage

Add @vite-pwa/nuxt module to nuxt.config.ts and configure it:

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@vite-pwa/nuxt'],
  pwa: {
    /* PWA options */
  },
})

The PWA options can also live in a pwa.config.ts file in your project root (or srcDir), which is loaded automatically:

// pwa.config.ts
import { definePwaConfig } from '@vite-pwa/nuxt'

export default definePwaConfig({
  registerType: 'autoUpdate',
  manifest: {
    name: 'My App',
  },
})

Use pwa.path in nuxt.config.ts to load the configuration from another file.

Read the 📖 documentation for a complete guide on how to configure and use this module.

⬆️ Migrating from v1

  • @vite-pwa/nuxt now uses unplugin-pwa and @vite-pwa/workbox-* instead of vite-plugin-pwa and workbox-*. If you import Workbox modules in a custom service worker, replace workbox-* imports with their @vite-pwa/workbox-swkit/* counterparts.
  • The workbox option is now generateSW (workbox still works but logs a deprecation warning).
  • The injectManifest strategy only injects the precache manifest into an existing service worker in the public folder. Service workers written in TypeScript or living outside public must use the buildSW strategy (strategies: 'buildSW' and the buildSW option).
  • The PwaModuleOptions type is now ModuleOptions (PwaModuleOptions is kept as a deprecated alias).
  • $pwa.isInstalled has been removed: use $pwa.isPWAInstalled instead.
  • $pwa.getSWRegistration() has been removed: use the service-worker:registered or service-worker:activated runtime hooks to access the service worker registration.
  • The PwaAppleImage, PwaAppleSplashScreenImage, PwaFaviconImage, PwaMaskableImage and PwaTransparentImage components are only registered when pwaAssets is enabled.
  • Deep imports from @vite-pwa/nuxt/* are no longer available.

⚡️ Examples

Run pnpm dev to start the Nuxt v4 example in development mode. To see the PWA in action, build or generate the Nuxt v3 example and serve it:

  • pnpm dev:build && pnpm test:build:serve: Nuxt build command + start server
  • pnpm dev:generate && pnpm test:generate:serve: Nuxt generate command + start server
Example Source Playground
Nuxt v5: Auto Update PWA GitHub Open in StackBlitz
Nuxt v4: Auto Update PWA GitHub Open in StackBlitz
Nuxt v3: Auto Update PWA GitHub Open in StackBlitz

👀 Full config

Check the following links for more details.

📄 License

MIT License © 2023-PRESENT Anthony Fu

About

Zero-config PWA Plugin for Nuxt 3

Topics

Resources

Code of conduct

Contributing

Stars

582 stars

Watchers

4 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages