Nuxt error tracking installation (v3.6 and below)
For older versions of Nuxt, you'll need to manually set up error tracking and source map uploads.
- 1
Installing PostHog SDK
RequiredYour goal in this step: Install the PostHog SDK.- Install
posthog-jsusing your package manager:
- Add your PostHog API key and host to your
nuxt.config.jsfile. You can find these in your project settings.
nuxt.config.js- Create a new plugin by creating a new file
posthog.client.jsin your plugins directory.
plugins/posthog.client.js - Install
Verify PostHog is initialized
CheckpointConfirm you can capture events with PostHogBefore proceeding, confirm that you can capture events using
posthog.capture('test_event').- 2
Manually capturing exceptions
RequiredYour goal in this step: Manually capture exceptions in your Nuxt application.To send errors directly using the PostHog client, import it and use the
captureExceptionmethod like this:VueOn the server side, you can use the
posthogobject directly.server/api/example.js - 3
Configuring exception autocapture
RecommendedYour goal in this step: Enable automatic exception tracking for your Nuxt application.Update your
posthog.client.jsto add an error hook.JavaScript - 5
PostHog is an all-in-one developer platform for building successful products. We provide product analytics, web analytics, session replay, error tracking, feature flags, experiments, surveys, LLM analytics, data warehouse, CDP, and an AI product assistant to help debug your code, ship features faster, and keep all your usage and customer data in one stack.

