---
title: Migrating to @nx/vitest from @nx/vite
description: This is a migration guide to switch to @nx/vitest from @nx/vite
sidebar:
  label: Migrate from @nx/vite
filter: 'type:Guides'
topics:
  - 'Vitest'
---

# Migrating from @nx/vite to @nx/vitest

## Overview

{% aside type="note" title="Nx 24 removes the @nx/vitest:test executor" %}
This guide describes the Nx 23 split. In Nx 24 the `@nx/vitest:test` executor is removed in
favour of the `@nx/vitest` plugin's inferred test target. If you are upgrading straight to
Nx 24, `nx migrate` converts these targets for you. See
[Removed Executors](/docs/reference/deprecated/removed-executors).
{% /aside %}

Vitest functionality has been split from `@nx/vite` into a standalone `@nx/vitest` package. This provides better separation of concerns and allows vitest to be used independently of vite.

## What changed

### Generators

- `@nx/vite:vitest` → `@nx/vitest:configuration`

### Executors

- `@nx/vite:test` → `@nx/vitest:test`

### Plugins

- `@nx/vite/plugin` (for vitest) → `@nx/vitest`

## Migration steps

### 1. Install @nx/vitest

```bash
npm install --save-dev @nx/vitest
# or
pnpm add -D @nx/vitest
# or
yarn add -D @nx/vitest
```

### 2. Update project.json

**Before:**

```json
{
  "targets": {
    "test": {
      "executor": "@nx/vite:test",
      "options": {
        "config": "vite.config.ts"
      }
    }
  }
}
```

**After:**

```json
{
  "targets": {
    "test": {
      "executor": "@nx/vitest:test",
      "options": {
        "config": "vite.config.ts"
      }
    }
  }
}
```

### 3. Update nx.json (if using plugin)

**Before:**

```json
{
  "plugins": [
    {
      "plugin": "@nx/vite/plugin",
      "options": {
        "testTargetName": "test"
      }
    }
  ]
}
```

**After:**

```json
{
  "plugins": [
    {
      "plugin": "@nx/vitest",
      "options": {
        "testTargetName": "test"
      }
    }
  ]
}
```

### 4. Update future generator usage

When adding vitest to new projects:

```bash
# Old
nx g @nx/vite:vitest my-project

# New
nx g @nx/vitest:configuration --project=my-project
```

## Backward compatibility

**Nx 23 removed all vitest support from `@nx/vite`.** The `@nx/vite:test` executor, the `@nx/vite:vitest` generator, and vitest target inference in `@nx/vite/plugin` no longer exist in v23. Everything is now provided exclusively by `@nx/vitest`.

If you are upgrading to Nx 23, the `ensure-vitest-package-migration` migration runs automatically via `nx migrate` and handles the conversion for you:

- Installs `@nx/vitest` when vitest usage is detected in the workspace.
- Swaps every `@nx/vite:test` reference (project targets and `targetDefaults`) to `@nx/vitest:test`.
- Splits vitest options out of `@nx/vite/plugin` registrations into dedicated `@nx/vitest` plugin entries.
- Adds an `@nx/vitest` plugin entry alongside any default-config `@nx/vite/plugin` registration.

See the [migration reference](/docs/technologies/build-tools/vite/migrations#ensure-vitest-package-migration-23) for full details on what the automated migration does. For manual steps, follow the guide above.

## No changes required for these files

- **vite.config.ts / vitest.config.ts**: No changes needed
- **Test files**: No changes needed
- **vitest.config.ts**: No changes needed

## Questions?

File an issue at https://github.com/nrwl/nx/issues
