# Upgrade a React App From Vite 5 to the Current Vite Major

Yes. An agent moves Vite and the plugins, Vitest and Storybook builder that must move with it, reruns build, tests and e2e, and opens a pull request.

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

## What the agent does

The agent clones the repository into its own sandbox and reads everything that depends on Vite, because the version in `package.json` is the smallest part of the job. In alan2207/bulletproof-react, the app in `apps/react-vite` asks for `vite` `^5.2.10` and its Yarn v1 `yarn.lock` holds 5.2.11. Around it sit `vitest` 2.1.4, `@vitejs/plugin-react` 4.2.1, `vite-tsconfig-paths` 4.3.2, `vite-node` 1.6.0, which the `run-mock-server` script uses to start the mock API, and Storybook 8.0.9 with `@storybook/react-vite` as the framework in `.storybook/main.ts`. Each of those declares which Vite majors it supports, so the agent reads their `peerDependencies` on npm and picks the newest release of each that accepts the target Vite.

Then it reads the config the upgrade can break. `vite.config.ts` sets `base: './'`, the React and tsconfig-paths plugins, port 3000 for `server` and `preview`, a Vitest `test` block with `globals`, `jsdom` and `src/testing/setup-tests.ts`, `optimizeDeps.exclude: ['fsevents']`, and a `build.rollupOptions` with `external: ['fs/promises']` and `output.experimentalMinChunkSize: 3500`. The `build` script runs `tsc && vite build --base=/`. The agent goes through Vite's migration guide for every major between 5 and the newest stable one and checks each listed change against these exact options, including the minimum Node.js version each major requires.

Before changing anything it records a baseline on the untouched branch, the same commands `.github/workflows/react-vite-ci.yml` runs: copy `.env.example` to `.env`, `yarn install`, `yarn build`, `yarn test --run`, `yarn lint` and `yarn check-types`, then `yarn build-storybook`. For the end-to-end job it copies `.env.example-e2e`, runs `yarn playwright install --with-deps` and `yarn test-e2e`, which starts the mock server under `pm2` and lets Playwright start `yarn dev` through `webServer` in `playwright.config.ts`. Anything that already fails is written down so it is not blamed on the upgrade.

Then it upgrades Vite and only the packages whose peer ranges force a move, with `yarn upgrade` on exact ranges so `yarn.lock` changes once, and runs every baseline command again. A failure is fixed in config or code with the smallest change, citing the migration guide entry it comes from; a deprecation warning that still builds is listed rather than silently changed. It compares the size of `dist/` before and after so a chunking change from `experimentalMinChunkSize` shows up in numbers.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "Upgrade Vite in apps/react-vite to the newest stable major. Read package.json, yarn.lock, vite.config.ts, .storybook/main.ts, playwright.config.ts, mock-server.ts and .github/workflows/react-vite-ci.yml first. Read the peerDependencies of vitest, @vitejs/plugin-react, vite-tsconfig-paths, vite-node and the Storybook packages, and upgrade only the ones the new Vite requires, each to the newest release that supports it. Read Vite's migration guide for every major in between and list each change with whether this config or code is affected. Record a baseline first, as the CI workflow does: yarn build, yarn test --run, yarn lint, yarn check-types, yarn build-storybook and the e2e job with yarn test-e2e. After upgrading, run all of them again and compare the size of dist. Fix only what the upgrade breaks, do not upgrade React, TypeScript, ESLint or anything unrelated, and do not fix failures that existed before. Open a pull request with the before and after output.",
  "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 scoped to `apps/react-vite`. The diff changes `vite` and the companion packages in `package.json`, the matching `yarn.lock` entries, and `vite.config.ts` or `.storybook/main.ts` only where a migration guide entry requires it. The description has a table of every package moved with old and new versions and the reason it moved, the list of breaking changes marked "affects us" or "does not", and the before and after output of each command, including the `dist/` sizes.

The pull request's checks run `react-vite-ci.yml` on GitHub: build, unit tests, lint and type check, then the Playwright job with its report uploaded as an artifact. The session transcript has the same commands from the sandbox, each with its full output.

Before merging, a reviewer checks that `yarn dev` and `yarn preview` still serve on port 3000, that the relative `base: './'` and the `--base=/` override in the `build` script still produce the asset paths the deployment expects, and that `yarn run-mock-server` still starts, since the end-to-end tests depend on it and `vite-node` moves with Vitest.

## Run it on every new Vite major

When Vite ships a new major, its plugins, Vitest and the Storybook builder catch up in their own releases afterwards. An automation in the Project that holds the repository, with this prompt and a `schedule` trigger whose `cron` is `0 9 * * 1` in your `timezone`, checks every Monday. When the lockfile already has the newest major, or a companion such as the Storybook builder does not support it yet, the run ends with a short answer saying which package is holding it back and opens no pull request.

For a repository with several Vite apps, a script on your own server can send one `POST /o/{org}/sessions` per app directory instead, with the directory in `input`. Each run gets its own sandbox and its own `node_modules`, and a start past the key's `max_concurrent` limit answers `202` with `status: "queued"` until a slot frees.

## Why run it on Rush?

A Vite major touches the dev server, the build, the test runner and the Storybook builder at once, and the only honest check is to run all of them before and after. On a laptop that means reinstalling `node_modules` twice, installing Playwright's browsers and leaving `pm2` processes behind. In a Rush sandbox the agent does all of it on a machine that exists for this run, including the e2e job with its mock server.

The pull request carries its own evidence: which packages moved and why, each migration entry checked against this config, and command output from before and after. A reviewer reads the table and the diff instead of repeating the upgrade locally to trust it.

## Frequently asked questions

### Will it upgrade Vitest and Storybook too?

Only as far as the new Vite requires. The agent reads each package's peer range and moves it to the newest release that supports the target Vite. If Storybook has no release that does yet, the run says so and stops instead of forcing a mismatched pair.

### We use npm or pnpm, not Yarn 1. Does that matter?

No. The agent reads the lockfile that is in the repository and uses that package manager's own upgrade command, so the lockfile changes the way your team's tooling expects.

### Does it change our Rollup options?

Only when a migration guide entry says an option changed or was removed. Options like `external` and `experimentalMinChunkSize` are checked against the guide, and any change is cited in the pull request with the entry it came from.

### Do the Playwright tests really run in the sandbox?

Yes. The agent installs Playwright's browsers with their system dependencies, starts the mock server the way `test-e2e` does, and runs the suite before and after the upgrade. The output is in the transcript.

## More Vite jobs

- [Add a Bundle Size Budget to a Vite App](https://getrush.ai/run/add-bundle-size-budget/vite/)
- [Fix TypeError: crypto.hash Is Not a Function After a Vite 7 Upgrade](https://getrush.ai/run/fix-crypto-hash-is-not-a-function/vite/)
- [Fix "The CJS build of Vite's Node API is deprecated" Warning in Vite 5](https://getrush.ai/run/fix-vite-cjs-node-api-deprecated/vite/)

## More jobs like this: Upgrade dependencies weekly

- [Upgrade a VS Code Extension to the Latest API](https://getrush.ai/run/upgrade-vscode-engine/vscode-extension/)
- [Upgrade Wagtail to the Latest Release](https://getrush.ai/run/upgrade-wagtail/wagtail/)
- [Upgrade Zod 3 to Zod 4 in a React App](https://getrush.ai/run/upgrade-zod/zod/)

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