# Upgrade a Vite React App to React 19

Yes. An agent moves your Vite app from React 18 to 19, bumps the testing and typing packages that must move with it, runs build, tests and types, and opens a PR.

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

## What the agent does

The agent starts by reading what the upgrade has to carry along, because React 19 is rarely a one-line bump. In an app like the `apps/react-vite` workspace of alan2207/bulletproof-react, `package.json` pins `react` and `react-dom` at `^18.3.1`, `@types/react` at `^18.3.1`, `@types/react-dom` at `^18.3.0`, `@testing-library/react` at `^15.0.5`, `react-router` at `^7.0.2`, `@tanstack/react-query` at `^5.32.0`, `react-helmet-async` at `^2.0.4`, `react-query-auth` at `^2.4.3`, `react-error-boundary` at `^4.0.13`, Storybook 8 through `@storybook/react-vite`, `vite` at `^5.2.10` and `vitest` at `^2.1.4`. The lockfile is `yarn.lock`, so the agent uses Yarn for every install. `src/main.tsx` already renders through `createRoot` from `react-dom/client` inside `React.StrictMode`, which means the legacy `ReactDOM.render` migration is not needed here, and `src/app/provider.tsx` wraps the tree in `React.Suspense`, `ErrorBoundary`, `HelmetProvider` and `QueryClientProvider`.

Next it checks each dependency's peer range against React 19 and separates the packages that must move from the ones that can stay. `@testing-library/react` 15 does not accept React 19, so it goes to 16, which also moves `@testing-library/dom` into an explicit dev dependency. `@types/react` and `@types/react-dom` go to their 19 lines, and the agent runs `yarn check-types`, the project's `tsc --noEmit` script, to find the typing changes 19 brings: `useRef` now requires an argument, and the React 19 types drop implicit `children` in a few places. The `src/components/ui` folder has 36 `React.forwardRef` wrappers around Radix primitives in `dropdown.tsx`, `drawer.tsx`, `form.tsx`, `label.tsx`, `switch.tsx` and `textarea.tsx`; they keep working on 19, so the agent leaves them alone and notes that `ref` as a plain prop is available for a later cleanup rather than mixing it into an upgrade.

Then it runs the project's own gates, in the order `.github/workflows/react-vite-ci.yml` runs them: `mv .env.example .env`, `yarn install`, `yarn build` (which is `tsc && vite build --base=/`), `yarn test` (Vitest with jsdom, `globals: true` and `src/testing/setup-tests.ts`, where MSW's server listens with `onUnhandledRequest: 'error'` and `vi.mock('zustand')` is set), `yarn lint` and `yarn check-types`. Test failures after a React major are usually the interesting part: `act` warnings now come from `react` rather than `react-dom/test-utils`, and the testing library's `renderApp` helper in `src/testing/test-utils.tsx` wraps `AppProvider` with a memory router from `react-router`, so the agent reads any failing test's output and fixes the cause, not the assertion. It also builds Storybook with `yarn build-storybook`, since `.storybook/main.ts` uses `@storybook/react-vite` and `react-docgen-typescript`, and reports whether Storybook 8 accepts React 19 at the version in the lockfile or needs a minor bump too.

Last, the agent reviews runtime behaviour that changes silently in 19: `ref` callbacks may now return a cleanup function, `useFormStatus` and form actions become available, and `<Context>` can be rendered directly as a provider. It greps `src/` for patterns that break, such as string refs, `defaultProps` on function components and `propTypes` (none in this app), and for the `react-helmet-async` provider, which it tests in the browser build because that package declares its own React peer range. The pull request lists every version that changed, every type fix, and the exact commands run with their output.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "Upgrade this Vite React app from React 18 to React 19 and open a pull request. Use the package manager the lockfile says. Bump react, react-dom, @types/react and @types/react-dom to 19, and move @testing-library/react and any other dependency whose peer range excludes React 19 to a version that accepts it; leave packages that already accept 19 unchanged. Run the project's build, test, lint and type-check scripts and, if Storybook is configured, its build. Fix type errors and test failures by fixing their cause, not by loosening assertions. Do not refactor forwardRef components or adopt new React 19 APIs in this PR. In the description list every version change, every code change with the React 19 behaviour behind it, and the output of each command.",
  "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 on its own branch that changes `apps/react-vite/package.json` and `yarn.lock`, plus the handful of source files the new types required. In an app like bulletproof-react that means `react`, `react-dom`, the two `@types` packages and `@testing-library/react` move, and a few components gain an explicit `useRef` initial value or a typed `children` prop. Nothing under `src/components/ui` is rewritten.

The description carries the output of `yarn build`, `yarn test`, `yarn lint`, `yarn check-types` and `yarn build-storybook` from the sandbox, and names any package the agent could not move because its peer range still excludes React 19, with the version it is waiting for. The repository's own `react-vite-ci.yml` runs on the pull request as well, so the same commands run a second time on GitHub.

Before merging, a reviewer reads the diff of `yarn.lock` for packages that moved as a side effect, checks that the typed `children` and `useRef` changes match how each component is used, and opens the app once with `yarn dev` to confirm the MSW-backed mock server and the routes still render. Then they decide whether the `ref`-as-prop cleanup is worth a follow-up issue.

## Run it on every Vite React app still on React 18

An organization with several front-end repositories sends one `POST /o/{org}/sessions` per repository with this prompt and the repository in `resources`. `GET /o/{org}/github` lists every repository the Rush GitHub App installation reaches, so a script can read each `package.json` from a clone, skip the ones already on React 19 or on Next.js, and start a run for the rest. Each run reads that app's own lockfile and peer ranges, so a Yarn project and an npm project each get the right install commands.

Give the API key a webhook URL and Rush POSTs `run.completed` or `run.failed` when each turn finishes, with `session_url` to read the pull request link. Send a fresh UUID as `request_id` with each request so a retried request returns the run it already started instead of opening a second pull request.

## Why run it on Rush?

A React major upgrade is a loop of install, build, test, read, fix, and most of the time goes to the packages around React rather than React itself. In its own sandbox the agent runs that loop with the project's real Yarn lockfile, Vitest setup and Storybook config, and every command's output is kept in the run's record, so the reviewer sees exactly which test failed before the fix and what it printed after. Nothing is installed on a laptop and no local `node_modules` is left half-upgraded.

The result is a pull request a reviewer can judge from the diff and the quoted output, with the packages that could not move named rather than forced. The same request runs across every React repository the team owns at once, each in its own sandbox, each opening its own pull request.

## Frequently asked questions

### Will it rewrite my forwardRef components to use ref as a prop?

No. React 19 still supports `forwardRef`, and the prompt tells the agent to leave those components alone so the diff stays an upgrade and not a refactor. It notes the opportunity in the pull request description; a follow-up run can do that migration on its own branch.

### What if a dependency has no React 19 release yet?

The agent does not force it with an override. It names the package, its current peer range and the version it is waiting for in the pull request, and stops at the point where the upgrade is honest. If the team wants to proceed anyway, a follow-up message to the same run can add a `resolutions` entry and re-run the tests.

### Does it work with pnpm or npm instead of Yarn?

Yes. The agent reads the lockfile that is present, `yarn.lock`, `pnpm-lock.yaml` or `package-lock.json`, and uses that package manager for installs so the lockfile stays consistent. The React 19 changes themselves are the same whichever manager you use.

### Will tests that pass on React 18 fail on 19?

Some can. The most common causes are the `act` import moving from `react-dom/test-utils` to `react`, Testing Library needing version 16 for React 19, and stricter effect timing in StrictMode. The agent fixes the cause in the test or component and quotes the before and after output rather than skipping the test.

## More Vite + React jobs

- [Write Playwright Tests for a Vite React App](https://getrush.ai/run/write-playwright-tests/vite-react/)
- [Write Vitest Tests for a Vite React App](https://getrush.ai/run/write-vitest-tests/vite-react/)
- [Add a Bundle Size Check to a Vite React App](https://getrush.ai/run/add-bundle-size-check/vite-react/)

## The same job on other stacks

- [Upgrade a Chrome Extension to React 19](https://getrush.ai/run/upgrade-react-19/chrome-extension/)

## More jobs like this: Upgrade dependencies weekly

- [Upgrade RQ 1.x to RQ 3 in a Flask App](https://getrush.ai/run/upgrade-rq/rq/)
- [Upgrade a Scrapy Project to the Latest Scrapy](https://getrush.ai/run/upgrade-scrapy/scrapy/)

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