Progressive Web Apps (PWAs) bridge the gap between web and native applications - offering offline access, installability, push notifications, and performance benefits. If you’re working with Vue 3, integrating PWA capabilities is straightforward thanks to the official plugin ecosystem.
In this blog, we’ll walk through how to transform your Vue app into a PWA using @vue/cli or Vite + Vue 3, with caching, icons, and a custom install prompt.
When it comes to professional Vue development, Zignuts stands out as a top-rated Vue development company. Whether you need to hire a skilled Vue developer or set up a dedicated team, Zignuts offers flexible engagement models tailored to your project requirements, ensuring high-quality, scalable, and efficient web solutions.
Prerequisites
Before diving in, make sure you have:
- Node.js ≥ 14.x
- Vue 3 project (created with Vue CLI or Vite)
- Basic familiarity with Vue project structure
1. Setting Up the PWA Plugin
If you’re using Vue CLI, simply run:
This modifies vue.config.js and adds a registerServiceWorker.js file automatically.
If you’re using Vite, use the official vite-plugin-pwa:
Then configure it in vite.config.js:
2. Understanding the Manifest File
The manifest. webmanifest (auto-generated if using Vue CLI or manually via Vite config) contains metadata
Place your icons in the public folder.
3. Register the Service Worker
For Vue CLI projects, it’s auto-included. For Vite:
Create a file (optional override):
This ensures the service worker is registered when your app is launched.
4. Test Offline Support
Run a production build :
Now open the app in Chrome → DevTools → Application → Service Workers → check “Offline” and reload — your app should still load!
5. Optional: Custom Install Prompt
Most browsers show the “Add to Home Screen” prompt automatically, but you can manually trigger it for better UX.
6. Automatic SW Updates
For Vite:
For Vue CLI:
Use the registerServiceWorker.js hooks to detect updates and notify users.
Verify Your PWA
Use Lighthouse in Chrome DevTools:
- Go to the “Lighthouse” tab
- Select “Progressive Web App”
- Click Generate report
Final Folder Structure