> ## Documentation Index
> Fetch the complete documentation index at: https://docs.useflytrap.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Use Flytrap with Vite

> Use Flytrap to catch & replay both front-end & back-end bugs with Vite

## Installing

Install the `useflytrap` package to your project.

<CodeGroup>
  ```bash npm theme={null}
  npm install useflytrap
  ```

  ```bash yarn theme={null}
  yarn add useflytrap
  ```

  ```bash pnpm theme={null}
  pnpm install useflytrap
  ```
</CodeGroup>

## Add Flytrap code transform

Add the Flytrap code transform to your Vite configuration, so that all your code gets properly processed for replaying. This is an example configuration of using Vite with a SvelteKit application.

<CodeGroup>
  ```typescript vite.config.ts theme={null}
  import { FlytrapTransformPlugin } from 'useflytrap/transform'
  import { sveltekit } from '@sveltejs/kit/vite'
  import { defineConfig } from 'vite'

  export default defineConfig({
  	plugins: [
      // only add in production
      ...(process.env.NODE_ENV === 'production' ? [FlytrapTransformPlugin.vite()] : []),
      sveltekit()
    ]
  })
  ```
</CodeGroup>

<Info>Keep in mind that the Flytrap Transform should come before plugins such as `sveltekit`</Info>

<Snippet file="create-config.mdx" />

<Info>In Next.js, your Flytrap config might get cached, so you need to delete the `.next` folder after changing the Flytrap config for the changes to be applied.</Info>

## Catch your first bug

Now your app will be enabled with Flytrap. You can test out the setup by throwing an error in your development environment.

<img height="200" src="https://mintcdn.com/flytrap-98/_ZYKplWiYxS4sMge/images/dashboard/capture.png?fit=max&auto=format&n=_ZYKplWiYxS4sMge&q=85&s=ce61d7b322d5d0cb849a4c651416a277" className="rounded-lg" className="rounded-lg" data-path="images/dashboard/capture.png" />

## Example

<Card
  title="Vite usage example"
  icon={
  <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
    viewBox="0 0 98.1 118">
  <path class="st0" fill="#FF3E00" d="M91.8,15.6C80.9-0.1,59.2-4.7,43.6,5.2L16.1,22.8C8.6,27.5,3.4,35.2,1.9,43.9c-1.3,7.3-0.2,14.8,3.3,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.4,4.4,9.9,3.5,15.3c-0.9,5.2-4.1,9.9-8.6,12.7l-27.5,17.5C44.8,102.5,42.9,103.3,40.9,103.9"/>
  </svg>
}
  href="https://github.com/useflytrap/flytrap-js/tree/main/examples/with-sveltekit"
>
  See how you can use Flytrap with Vite in an example SvelteKit application
</Card>
