# Add PWA Support to a Vue App

Yes. An agent adds vite-plugin-pwa to your Vue app, builds the manifest and service worker from the icons you already have, and opens a PR with e2e passing.

[Run this on Rush](https://cloud.getrush.ai/run/add-pwa-support/vue/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent starts from what the app already has. In an app shaped like realworld-apps/vue-realworld-example-app, `package.json` pins `vue` 3.5, `pinia` 3, `vue-router` 5 and `vite` 8 with `@vitejs/plugin-vue`, installs with Bun (`bun.lock`), and runs the official RealWorld Playwright suite from the `realworld` submodule through `playwright.config.ts`, whose `webServer` is `bun run serve` on port 8080. `public/manifest.json` is a leftover from the Vue CLI days: it names 192 and 512 pixel icons under `public/img/icons`, a `standalone` display and a `start_url` of `/index.html`, but `index.html` never links it, there is no `theme-color` meta tag and no service worker exists. `src/common/config.js` reads the API base from `VITE_API_URL`, and `src/common/jwt.service.js` keeps the login token in local storage.

The agent adds `vite-plugin-pwa` as a dev dependency and registers `VitePWA` in `vite.config.js` with `registerType: 'autoUpdate'`, a manifest built from the existing icon files (name and short name set to the app's `Conduit` title, `start_url` corrected to `/`, the `theme_color` and `background_color` the old file carried) and a `workbox` section that precaches the built assets and sets `navigateFallback` to the index so a deep link like `/article/some-slug` opens offline. Requests to the API host are left to the network: the app sends the `Token` header on every call, so caching responses would keep private data on disk and show stale feeds. `public/manifest.json` is deleted, since the plugin now writes `manifest.webmanifest` and injects its link, and `index.html` gains the `theme-color` meta and the `apple-touch-icon` link for the 180 pixel icon already in the repository.

In `src/main.js` the agent registers the worker with `registerSW` from `virtual:pwa-register` after `app.mount`, so a failed registration never blocks the first render. Because `devOptions` stays off, `bun run serve` and the Playwright `webServer` behave as before, and the ESLint config in `eslint.config.mjs` needs no new global.

To prove it, the agent runs `bun run build` and lists `dist` to show `sw.js`, the Workbox runtime and `manifest.webmanifest`, serves the build with `bun run preview` and opens it in the sandbox browser to confirm the manifest and worker are picked up, then runs `bun run test:e2e` and `bun run test:e2e:security`, the same commands `playwright.yml` and `security-tests.yml` run, plus `bun run lint` and `bun run format:check` from `lint.yml`. The `deploy.yml` workflow zips `dist`, so the worker ships with the next release without any change there.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Make this Vue app a progressive web app and open a pull request. Read package.json, vite.config.js, index.html, src/main.js, public/manifest.json, the files under public/img/icons, playwright.config.ts, eslint.config.mjs and the workflows under .github/workflows first. Add vite-plugin-pwa as a dev dependency with bun and register VitePWA in vite.config.js with registerType autoUpdate, a manifest built from the existing icons with start_url set to /, and a workbox config that precaches the build and uses the index as navigateFallback; do not add runtime caching for the API host. Delete public/manifest.json, add the theme-color meta and the apple-touch-icon link to index.html, and register the worker in src/main.js with registerSW from virtual:pwa-register after the app mounts. Leave devOptions off so bun run serve is unchanged. Run bun run build and list dist, serve the build with bun run preview and check the manifest and worker in the browser, then run bun run lint, bun run format:check, bun run test:e2e and bun run test:e2e:security, and paste the results in the pull request description. Do not change any store, view or component.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request with `vite-plugin-pwa` in `package.json` and `bun.lock`, the `VitePWA` block in `vite.config.js`, the two tags in `index.html`, the `registerSW` call in `src/main.js` and the deleted `public/manifest.json`. The description shows the `dist` listing with the worker and manifest, a screenshot of the installed app from the sandbox browser, and the lint, format and Playwright results.

The repository's `Format Check`, `Playwright Tests` and `Security Tests` workflows run on the pull request, so the e2e suite from the `realworld` submodule checks that routing, login and the article pages behave as before behind the worker.

A reviewer checks that no API route is in the runtime cache, that `start_url` is `/` and not the old `/index.html`, that the worker registers after mount, and that `devOptions` is off so local development did not change. Then they decide whether `autoUpdate` or a prompt on update fits their users.

## Run it on every new frontend release

A team with several Vue apps starts one run per repository with `POST /o/{org}/sessions`, this prompt and the repository in `resources`. Each run reads that app's own icons, API client and e2e setup, so an app that already links a manifest keeps it and only gains the worker, and each run ends in its own pull request.

The key's `webhook_url` receives `run.completed` for each run it starts, with a `session_url` for the result, so a script can post the pull request links and the `dist` listings to the team channel.

## Why run it on Rush?

A service worker is the one piece of a frontend that can break an app for every returning visitor at once, by caching the wrong thing or by never updating. In a Rush sandbox the agent builds the app, serves the real `dist`, opens it in a browser with the worker active and runs the full Playwright suite against it, and every command and screenshot stays in the run's transcript, so the pull request shows the app working behind the worker rather than asserting it.

The result passes the repository's own gates, the lint and format check and both Playwright workflows, before a reviewer opens it, and the API stays uncached by design rather than by accident. The same request works unchanged on every Vue app the team ships, each in its own sandbox at the same time.

## Frequently asked questions

### Why not cache the API responses for offline reading?

Because every API call carries the user's `Token` header and returns data specific to that user, including the feed of followed authors. Caching those responses would keep private data on disk and serve stale feeds after a follow or an edit. The app shell works offline; the data stays live.

### Does the existing public/manifest.json get reused?

Its values do. The plugin generates `manifest.webmanifest` from the config in `vite.config.js`, so the agent moves the icon entries, colors and display mode there, fixes `start_url` to `/`, and deletes the old file so two manifests are never served.

### Will the Playwright suite still run against the dev server?

Yes. `playwright.config.ts` starts `bun run serve`, and the plugin's `devOptions` stay off, so the dev server serves no worker and the suite runs as before. The agent also runs the suite against `bun run preview` with the worker active and reports both.

### How do users get a new version?

`registerType: 'autoUpdate'` makes the worker activate the new build on the next load without a prompt. If your team prefers an in-app prompt, the plugin's `prompt` mode exposes `needRefresh` from `virtual:pwa-register/vue`, which is a small follow-up to the same file.

## More Vue jobs

- [Convert a Vue App From JavaScript to TypeScript](https://getrush.ai/run/convert-javascript-to-typescript/vue/)
- [Dockerize a Vue App](https://getrush.ai/run/dockerize-app/vue/)
- [Find Dead Code in a Vue Project](https://getrush.ai/run/find-dead-code/vue/)

## The same job on other stacks

- [Add PWA Support to an Angular App](https://getrush.ai/run/add-pwa-support/angular/)
- [Add PWA Support to an Astro Site](https://getrush.ai/run/add-pwa-support/astro/)
- [Add PWA Support to a Docusaurus Site](https://getrush.ai/run/add-pwa-support/docusaurus/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
