# Add Page Titles per Route to a Vue App

Yes. An agent gives every Vue Router route a title, sets it in an afterEach hook, updates article and profile titles after their data loads, and opens a PR.

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

## What the agent does

The agent reads the router and the shell before it writes a title. In an app shaped like realworld-apps/vue-realworld-example-app, `package.json` has `vue` ^3.5, `vue-router` ^5.1 and `pinia` ^3.0, installs with `bun`, and runs `vite` for `serve`, `eslint src` for `lint`, `prettier --check` for `format:check` and `playwright test` for `test`. `index.html` carries the one `<title>Conduit</title>` every page shows. `src/router/index.js` declares ten named routes, `home`, `home-tag`, `login`, `register`, `settings`, `profile`, `profile-favorites`, `article`, `editor-new` and `article-edit`, each lazy-loading a view from `@/views`, with `meta: { requiresAuth: true }` on three of them and nothing else in `meta`.

`src/main.js` is where navigation is already intercepted: a `router.beforeEach` awaits `auth.checkAuth()` and redirects to `/login` when a route needs a signed-in user. It also exposes `window.__conduit_debug__` for the Playwright suite, so the agent knows the end-to-end tests read app state through that object and not through the document title. `src/views/Article.vue` fetches the article in `beforeRouteEnter` through `useArticleStore`, so its title is known only after that store resolves; `src/views/Profile.vue` shows `Loading profile...` until `profileLoaded` is true, and `src/views/Home.vue` switches between a global feed, a following feed and a tag feed from `route.params.tag` and `route.query.feed`.

The agent adds a `title` to each route's `meta`: `Sign in`, `Sign up`, `Settings`, `New Article`, `Edit Article`, `Home`, and leaves `article`, `profile` and `profile-favorites` with a placeholder because their titles come from data. It adds `src/common/title.js` with a `setTitle(parts)` helper that joins the parts with the site name, `Conduit`, and installs a `router.afterEach` in `src/main.js` that calls it with `to.meta.title`, so a route with a static title is right the moment navigation finishes. `Home.vue` sets `#tag` titles from the route param through a `watch`, `Article.vue` calls `setTitle(article.title)` once the store has the article, and `Profile.vue` sets `@username` and `@username's favorites` when `profileLoaded` turns true. `src/App.vue` stays untouched because the hook lives beside the existing guard.

The repository has no unit test runner, only Playwright over the `realworld` submodule's specs, so the agent adds a `document.title` check to a local spec rather than to the shared suite: `e2e/titles.spec.ts` visits `/login`, `/register` and `/` and asserts `toHaveTitle`, then opens an article from the global feed and asserts the title changes to the article's heading. `playwright.config.ts` already starts `bun run serve` on port 8080 with `reuseExistingServer`, so the new spec runs with the existing command. The agent runs `bun run lint`, `bun run format:check`, `bun run build` and `bun run test`, and keeps all four outputs.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "Add per-route page titles to this Vue 3 app and open a pull request. Read package.json, index.html, src/main.js, src/router/index.js, src/App.vue, src/views/Home.vue, src/views/Article.vue, src/views/Profile.vue and playwright.config.ts first. Add a meta.title to each route that has a static title, write a small setTitle helper in src/common/title.js that appends the site name, and call it from a router.afterEach in src/main.js beside the existing beforeEach guard. In Home.vue set a tag title from the route param, in Article.vue set the article's title once the store has loaded it, and in Profile.vue set the username and favorites titles when the profile has loaded. Do not change the realworld submodule. Add e2e/titles.spec.ts with Playwright assertions on document.title for the static pages and for an article opened from the feed, and include it in the Playwright config without changing the shared specs. Run bun run lint, bun run format:check, bun run build and bun run test, and paste the output in the pull request.",
  "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 that adds `meta.title` lines in `src/router/index.js`, a new `src/common/title.js`, an `afterEach` in `src/main.js`, small edits in three views, a `titles.spec.ts` and a `testDir` or `testMatch` change in `playwright.config.ts` so both the shared specs and the new one run. The description lists every route and the title it gets, with the dynamic ones marked, and pastes the ESLint, Prettier, Vite build and Playwright output.

The repository's `Format Check` workflow runs on the pull request; the Playwright run is in the description because the repository's own workflows build and release rather than test on pull requests.

A reviewer checks that the title shows the site name last, that the article page does not flash the placeholder for long, that the tag feed title updates when the tag changes without a full navigation, and that the shared RealWorld specs were not edited. They merge when the format check is green and the pasted Playwright summary has no failures.

## Run it on every Vue app with one title for every page

A team with several Vue front ends sends one `POST /o/{org}/sessions` per repository with this prompt and the repository in `resources`. Each run reads its own `src/router`, so an app that already sets titles through a plugin gets only the routes it missed, and each opens a pull request on its own branch.

Send a `request_id` with each call so a retry returns the run already started, and set a `webhook_url` on the key so `run.completed` arrives with `session_url` when each turn ends and your server can post the pull request link where the team reads it.

## Why run it on Rush?

Titles are easy to get almost right and hard to prove right: the static ones need a navigation hook, the dynamic ones need to wait for data, and the only honest check is a browser reading `document.title` after each step. In a Rush sandbox the agent starts the Vite dev server, runs Playwright against it, and keeps the browser's output in the run's record beside the pull request.

On a laptop this is a small change spread across the router, the entry file, three views and the test setup, with a dev server to keep running. The agent makes the whole change in one pass, and a follow-up such as "use the article's description for the meta description too" wakes the same parked sandbox and lands in the same pull request.

## Frequently asked questions

### Why not use a head-management library?

The app has no head library in `package.json` and the only tag it needs to manage is `<title>`. A `router.afterEach` hook and a helper of a few lines do that without a new dependency. If the app later needs per-page meta tags, the helper is the one place to replace.

### What does the tab show while an article loads?

The route's placeholder, which the `afterEach` hook sets as soon as navigation finishes. `Article.vue` fetches its data in `beforeRouteEnter`, so by the time the view mounts the store has the article and the title is replaced in the same tick; the placeholder is for a slow API, not the normal case.

### Why are the shared RealWorld specs not extended?

They live in the `realworld` git submodule, which is a separate repository pinned by commit, so a change there would not land in this pull request. The agent adds a local spec under `e2e/` and widens `playwright.config.ts` to run both directories.

### Does the title put user input into the page?

Only through `document.title`, which the browser treats as text, never as HTML. An article titled with angle brackets shows them literally in the tab. The helper does no string concatenation into the DOM.

## More Vue jobs

- [Persist Pinia State in a Vue App from a Linear Issue](https://getrush.ai/run/add-pinia-persistence/vue/)
- [Add PWA Support to a Vue App](https://getrush.ai/run/add-pwa-support/vue/)
- [Convert a Vue App From JavaScript to TypeScript](https://getrush.ai/run/convert-javascript-to-typescript/vue/)

## The same job on other stacks

- [Add Page Titles per Route to an Angular App](https://getrush.ai/run/add-page-titles/angular/)
- [Set a Document Title per Page in a SolidJS App](https://getrush.ai/run/add-page-titles/solidjs/)

## More jobs like this: Hand off a long task

- [Add Pagination to an aiohttp App](https://getrush.ai/run/add-pagination/aiohttp/)

## 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/)
