> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt # Upload source maps for Vite Canonical URL: https://posthog.com/docs/error-tracking/upload-source-maps/vite > **Cloud region:** This page uses US Cloud hosts. For an EU Cloud project, use `https://eu.i.posthog.com` instead of `https://us.i.posthog.com` (ingestion host), and use `https://eu.posthog.com` instead of `https://app.posthog.com` (app host for links). ## On this page - [AI wizard](#ai-wizard) - [Manual setup](#manual-setup) - [Install the PostHog Rollup plugin](#install-the-posthog-rollup-plugin) - [Add PostHog plugin to your Vite config](#add-posthog-plugin-to-your-vite-config) - [Verify source map upload and injection](#verify-source-map-upload-and-injection) ## AI wizard Set up source map uploading automatically with our wizard by running this command in your project directory with your terminal (it also works for [LLM coding agents](https://posthog.com/blog/envoy-wizard-llm-agent.md) like Cursor and Bolt): `npx @posthog/wizard upload-source-maps` ## Manual setup 1. 1 ## Install the PostHog Rollup plugin Required Vite uses Rollup under the hood, so you can use the PostHog Rollup plugin to upload source maps: ```shell npm install @posthog/rollup-plugin ``` 2. 2 ## Add PostHog plugin to your Vite config Required Add the PostHog plugin to your `vite.config.js` file: vite.config.js ```javascript import { defineConfig } from 'vite' import posthog from '@posthog/rollup-plugin' export default defineConfig({ plugins: [ posthog({ personalApiKey: process.env.POSTHOG_API_KEY!, // Personal API Key projectId: process.env.POSTHOG_PROJECT_ID, // Project ID host: process.env.POSTHOG_HOST, // (optional) defaults to https://us.i.posthog.com sourcemaps: { // (optional) enabled: true, // (optional) Enable sourcemaps generation and upload, defaults to true releaseName: 'my-application', // (optional) Release name releaseVersion: '1.0.0', // (optional) Release version deleteAfterUpload: true, // (optional) Delete sourcemaps after upload, defaults to true }, }), ], }) ``` Set the following environment variables: | Environment variable | Description | | --- | --- | | `POSTHOG_API_KEY` | [Personal API key](https://app.posthog.com/settings/user-api-keys#variables) with at least `write` access on `error tracking` | | `POSTHOG_PROJECT_ID` | Project ID you can find in your [project settings](https://app.posthog.com/settings/project#variables) | | `POSTHOG_HOST` | (optional) Your PostHog instance URL. Defaults to `https://us.i.posthog.com` | **Using CI/CD?** Add these environment variables to your CI/CD service's project settings to automatically upload source maps during production builds. 3. ## Verify source map upload and injection Checkpoint Confirm source maps were successfully uploaded: 1. Go to your [symbol sets in PostHog](https://app.posthog.com/error_tracking/configuration#selectedSetting=error-tracking-symbol-sets) and verify your latest upload appears. 2. Check your production JavaScript files in browser dev tools. They should include a source map reference comment: ```javascript //# chunkId=0197e6db-9a73-7b91-9e80-4e1b7158db5c ```