Skip to main content
The @sentry/nuxt package provides comprehensive error tracking and performance monitoring for Nuxt applications, with support for both client and server environments.

Prerequisites

  • Node.js 18.19.1 or newer
  • Nuxt 3.7.0 or newer (3.14.0+ recommended) or Nuxt 4.x
  • A Sentry account and project DSN
Nuxt 3.14.0+ is recommended for the best experience. Older versions are supported but may have limitations.

Installation

1

Install the Package

Install @sentry/nuxt using your preferred package manager:
Current Version: 10.42.0
2

Register the Sentry Module

Add the Sentry module to your nuxt.config.ts:
3

Create Client Configuration

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

Create Server Configuration

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

Verify Installation

Create a test page to verify Sentry is working:
Visit the page and click the button. Check your Sentry dashboard to see the error.

Configuration Options

Configure Sentry in your nuxt.config.ts:

Error Handling

Automatic Error Capture

The SDK automatically captures:
  • Unhandled exceptions on client and server
  • Vue errors and warnings
  • API errors
  • Server middleware errors

Manual Error Capture

In Vue components:

In Server API Routes

In Server Middleware

Performance Monitoring

Automatic Instrumentation

The SDK automatically creates spans for:
  • Page loads and navigation
  • API requests
  • Server routes
  • Database queries (with integrations)

Custom Spans

In components:
In server routes:

Setting Context

User Context

Tags and Extra Context

Composables

useSentry Composable

Create a custom composable for easier Sentry usage:
Use it in components:

Session Replay

Configure Session Replay in your client config:

Pinia Integration

Track Pinia store actions:

Source Maps

Source maps are automatically uploaded when configured in nuxt.config.ts:

Advanced Configuration

Environment Detection

Sampling

Filtering Events

Runtime Configuration

Use runtime config for dynamic DSN:
Then in your Sentry config:

Troubleshooting

Errors Not Captured

  1. Ensure the Sentry module is registered in nuxt.config.ts
  2. Check that both sentry.client.config.ts and sentry.server.config.ts exist
  3. Verify DSN is correct in both configs

Source Maps Not Working

  1. Check SENTRY_AUTH_TOKEN is set correctly
  2. Verify org and project match your Sentry organization
  3. Ensure sourceMapsUploadOptions is configured

Performance Data Missing

  1. Ensure tracesSampleRate is greater than 0
  2. Check that Sentry module is loaded before your app
  3. Verify Sentry is initialized in both client and server configs
Make sure to create both sentry.client.config.ts and sentry.server.config.ts in your project root, not in a subdirectory.

Module Not Loading

If the Sentry module isn’t loading:
  1. Update to the latest @sentry/nuxt version
  2. Clear .nuxt directory: rm -rf .nuxt
  3. Reinstall dependencies
  4. Check Nuxt version compatibility

Next Steps