
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
@posthog/nuxt
Advanced tools
Please see the main PostHog Error tracking docs.
pnpm add @posthog/nuxt
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@posthog/nuxt'], // Add module reference
sourcemap: { client: 'hidden' }, // Make sure to set it (otherwise client sourcemaps will not be generated)
nitro: {
rollupConfig: {
output: {
sourcemapExcludeSources: false, // Make sure to set it (otherwise server sourcemaps will not be generated)
},
},
},
posthogConfig: {
host: 'http://localhost:8010', // (optional) Host URL, defaults to https://us.posthog.com
publicKey: 'public api key', // Your public web snippet key. You can find it in settings
clientConfig?: Partial<PostHogConfig> // (optional) It will be passed to the posthog-js client on init in vue
serverConfig?: PostHogOptions // (optional) It will be passed to the posthog-node client on init in nitro. Please note that this client instance is intended for error-tracking purposes only
sourceMaps: {
enabled: true, // Enables sourcemaps generation and upload
envId: '2', // Environment ID, see https://app.posthog.com/settings/environment#variables
project: 'my-application', // (optional) Project name, defaults to git repository name
version: '1.0.0', // (optional) Release version, defaults to current git commit
personalApiKey: 'personal api key', // Your personal API key. You can generate it in settings -> Personal API keys
},
},
})
// some-file.vue
const { $posthog } = useNuxtApp()
Q: I see typescript errors in the posthog config after adding this module
A: It is possible that after adding a new module to `modules` typescript will complain about types. Solution is to remove `.nuxt` directory and regenerate it by running `build` command you are using. This will properly regenerate config types.
Q: I see stack traces but I do not see line context in the error tracking tab
A: Double check whether you enabled sourcemaps generation in the nuxt config both for vue and nitro. It is covered in the docs.
pnpm ipnpm buildnpm inpm run buildnode .output/server/index.mjsFAQs
Nuxt module for Posthog 🦔
We found that @posthog/nuxt demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 14 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.