Skip to main content
The @sentry/vue package provides error tracking and performance monitoring for Vue.js applications. It supports both Vue 2.x and Vue 3.x.

Prerequisites

  • Node.js 18 or newer
  • Vue.js 2.x or 3.x
  • A Sentry account and project DSN

Installation

1

Install the Package

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

Initialize Sentry for Vue 3

Initialize Sentry as early as possible in your application:
Pass your Vue app instance to Sentry.init() to enable automatic component tracking and Vue-specific error handling.
3

Initialize Sentry for Vue 2

For Vue 2 applications, pass the Vue constructor instead:
4

Verify Installation

Test that Sentry is working:
Check your Sentry dashboard to see the error.

Vue Router Integration

With Vue Router

For automatic page load and navigation tracking:

Without Vue Router

If you’re not using Vue Router, omit the router option:

TanStack Router Integration

If you use TanStack Router for Vue instead of Vue Router:
The TanStack Router integration is exported from @sentry/vue/tanstackrouter.

Error Tracking

Automatic Error Capture

The SDK automatically captures:
  • Errors thrown in component lifecycle hooks
  • Errors in event handlers
  • Errors in watchers
  • Errors in render functions

Manual Error Capture

In Composition API

Setting Context

User Context

Tags and Context

Performance Monitoring

Component Tracking

Sentry automatically tracks Vue component lifecycle performance when you pass the app instance:

Custom Spans

Pinia Integration

Track Pinia store actions:

Session Replay

Capture session replays to see what users experienced:

Privacy Controls

Advanced Configuration

TypeScript Support

The SDK includes TypeScript definitions:

Custom Error Handler

If you have a custom error handler, make sure Sentry is initialized first:

Filtering Components

Control which components are tracked:

Troubleshooting

Source Maps

For Vite projects:
For Vue CLI / Webpack:

Errors Not Being Captured

Make sure:
  1. Sentry.init() is called before creating the Vue app
  2. You passed the app instance (Vue 3) or Vue constructor (Vue 2)
  3. The error is not caught by a try/catch without re-throwing
For Vue 3, you must pass the app instance to Sentry.init(). For Vue 2, pass the Vue constructor.

Performance Not Tracked

Ensure:
  1. tracesSampleRate is set to a value greater than 0
  2. The router is passed to browserTracingIntegration
  3. You’re using a supported router (Vue Router or TanStack Router)

Next Steps