Skip to main content
The Sentry Nuxt SDK provides comprehensive error monitoring and performance tracking for Nuxt 3 applications with support for server-side rendering, static site generation, and the Nuxt module system.

Installation

1

Install Package

2

Add to Nuxt Config

Add Sentry to your nuxt.config.ts:
3

Create Config Files

Create sentry.client.config.ts and sentry.server.config.ts in your project root.

Version Compatibility

  • Nuxt 3.14+: Recommended
  • Nuxt 3.7+: Minimum supported version
  • Vue 3: Required
  • Works with both SSR and static generation

Basic Setup

Client Configuration

Create sentry.client.config.ts in your project root:

Server Configuration

Create sentry.server.config.ts in your project root:

Error Handling

Component Errors

Vue component errors are automatically captured:

Server Routes

API Routes with Spans

Composables and Plugins

Custom Error Handler Plugin

Composable with Tracking

Server Middleware

Performance Monitoring

Page navigation is automatically tracked when the Sentry module is configured.

Custom Spans

Database Queries

Context and User Information

Setting User Context

Adding Context

Runtime Config

Use Nuxt runtime config for environment variables:
Access in your config files:

Source Maps

Configure source maps upload in nuxt.config.ts:

Environment Variables

Create a .env file:

Deployment

Add environment variables in Vercel:
  • SENTRY_DSN
  • SENTRY_AUTH_TOKEN
  • SENTRY_ENVIRONMENT

Best Practices

Module Configuration

Add Sentry module to nuxt.config.ts for automatic setup.

Separate Configs

Use separate config files for client and server initialization.

Runtime Config

Use Nuxt runtime config for environment-specific values.

Source Maps

Always configure source maps upload for production.

Troubleshooting

Ensure:
  1. @sentry/nuxt/module is in the modules array
  2. Config files are in the project root
  3. DSN is correctly set
Verify:
  1. SENTRY_AUTH_TOKEN is set
  2. sourceMapsUploadOptions is configured
  3. Check build output for upload logs
Check:
  1. Both client and server configs are initialized
  2. DSN is the same in both configs
  3. Network requests to Sentry are not blocked

Next Steps

Server Routes

Monitor API endpoints and server functions

Composables

Track custom composables and utilities

Session Replay

Debug with session recordings

Vue Integration

Advanced Vue-specific features