Upload source maps for Nuxt
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):
Nuxt v3.7 and above
For Nuxt v3.7 and above, the @posthog/nuxt module automatically handles source map generation and upload during the build process.
No manual configuration is needed – follow the Nuxt Error Tracking installation guide to set up the module, and source maps are automatically generated and uploaded when you build your project.
Nuxt v3.6 and below
For older versions of Nuxt, you'll need to manually configure source map generation and upload using the PostHog CLI.
- 1
Install the PostHog CLI
Required - 2
Authenticate the PostHog CLI
RequiredLog in to PostHog. This opens your browser, where you approve the login:
TerminalIf posthog-cli is already logged in on this machine, import that login instead:
TerminalThese CI providers can upload with the job's OIDC token, so you don't store a personal API key in CI.
- Logged in with
hog auth login, run this once in the repository:
Terminal- An organization admin approves the request in PostHog.
- Add the
hostandprojectIdthat hog prints toposthog.json, and add the snippet it prints to the job.
In GitHub Actions, the job needs the
id-token: writepermission:YAMLRemove any personal API key from the job. A key wins over the OIDC token.
Set these environment variables in the job:
Environment variable Description Source HOG_HOSTThe PostHog host to connect to, such as https://eu.posthog.com[default: https://us.posthog.com]Project settings HOG_PROJECT_IDPostHog project ID Project settings HOG_PERSONAL_API_KEYPersonal API key with the error_tracking:writescopeAPI key settings hog reads only the
HOG_*names. The PostHog build plugins and upload scripts still pass the oldPOSTHOG_CLI_*names to hog for now, with a warning for each one. Ahogcommand you run yourself needs theHOG_*names. The migration guide lists each rename. - 3
Generate source maps during build
RequiredYou can hook into the
closeevent to generate and upload source maps for your Nuxt application like this:nuxt.config.js - 4
Build your project for production
RequiredBuild your project for production by running the following command:
TerminalPost-build scripts should automatically generate and upload source maps to PostHog.
Verify source map upload
CheckpointConfirm source maps are being properly uploadedBefore proceeding, confirm that source maps are being properly uploaded.
You can verify the injection is successful by checking your
.mjsbundle files for//# chunkId=comments. The--delete-afterflag removes the.mapfiles after upload so they won't be exposed in your public deployment. PostHog already has them. Make sure to serve the injected JS bundles in production, PostHog will use the//# chunkIdcomments to match them with the uploaded source maps.- 5
Next steps
After configuring PostHog, update your build and deployment process to serve bundles injected with the
chunkIdcomments. PostHog relies on these comments to display the correct stack traces. Remember to export the required environment variables in your deployment process.





