---
title: "Vite Integration"
description: "Integrate Lighthouse audits into your Vite development server with automatic route discovery and HMR support."
canonical_url: "https://unlighthouse.dev/integrations/vite"
---

> Index of every page on this site: [llms.txt](https://unlighthouse.dev/llms.txt)

::warning
**Deprecated**: This integration will be removed in v1.0. Use [CLI](https://unlighthouse.dev/integrations/cli) or [CI](https://unlighthouse.dev/integrations/ci) instead. See [deprecation notice](https://unlighthouse.dev/integration-deprecations).
::

Lighthouse auditing within your Vite dev environment with real-time performance feedback.

## Install

::code-group
```bash [yarn]
yarn add -D @unlighthouse/vite
```

```bash [npm]
npm install -D @unlighthouse/vite
```

```bash [pnpm]
pnpm add -D @unlighthouse/vite
```
::

### Git ignore reports

Unlighthouse will save your reports in `outputDir` (`.unlighthouse` by default),
it's recommended you .gitignore these files.

```shell
.unlighthouse
```

## Usage

To begin using Unlighthouse, you'll need to add the plugin to `plugins`.

When you run your Vite app, it will give you the URL of client, only once you visit the client will Unlighthouse start.

```ts vite.config.ts
import Unlighthouse from '@unlighthouse/vite'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    Unlighthouse({
      // config
    })
  ]
})
```

### Providing Route Definitions

If you're using the [vite-plugin-pages](https://github.com/hannoeru/vite-plugin-pages) plugin, you can provide route definitions to Unlighthouse.

You will need to hook into the plugin using the following code.

```ts vite.config.ts
import { useUnlighthouse } from 'unlighthouse'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    Pages({
      // ...
      onRoutesGenerated(routes) {
        // tell Unlighthouse about the routes
        const unlighthouse = useUnlighthouse()
        if (unlighthouse?.hooks)
          unlighthouse.hooks.callHook('route-definitions-provided', routes)
      }
    }),
  ]
})
```

## Configuration

You can either configure Unlighthouse via the plugin, or you can provide a  [config file](https://unlighthouse.dev/guide/guides/config) file
in the root directory.

### Example

```ts vite.config.ts
import Unlighthouse from '@unlighthouse/vite'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    Unlighthouse({
      scanner: {
        // simulate a desktop device
        device: 'desktop',
      }
    })
  ]
})
```

## Sitemap

See the full [sitemap](https://unlighthouse.dev/sitemap.md) for all pages.
