Upload source maps for Vite
Contents
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 like Cursor and Bolt):
Manual setup
- 1
Install the PostHog Rollup plugin
RequiredVite uses Rollup under the hood, so you can use the PostHog Rollup plugin to upload source maps:
Terminal - 2
Add PostHog plugin to your Vite config
RequiredAdd the PostHog plugin to your
vite.config.jsfile:vite.config.jsSet the following environment variables:
Environment variable Description POSTHOG_API_KEYPersonal API key with at least writeaccess onerror trackingPOSTHOG_PROJECT_IDProject ID you can find in your project settings POSTHOG_HOST(optional) Your PostHog instance URL. Defaults to https://us.i.posthog.comUsing CI/CD?Add these environment variables to your CI/CD service's project settings to automatically upload source maps during production builds.
Verify source map upload and injection
CheckpointConfirm source maps were successfully uploaded:
Go to your symbol sets in PostHog and verify your latest upload appears.
Check your production JavaScript files in browser dev tools. They should include a source map reference comment:
JavaScript