Skip to main content
The Sentry Svelte SDK provides error monitoring and performance tracking for standalone Svelte applications. For SvelteKit projects, use the @sentry/sveltekit SDK.

Installation

Basic Setup

Initialize Sentry in your entry point (main.js or main.ts) before bootstrapping your Svelte app:

Error Tracking

Automatic Error Capture

Uncaught errors are automatically captured:

Manual Error Capture

Performance Monitoring

Browser Tracing

Track page load and navigation performance:

Custom Performance Spans

Context & Breadcrumbs

User Context

Custom Context & Tags

Session Replay

Capture session replays to understand user behavior:

Svelte Stores Integration

Track store updates:

Advanced Features

Collect feedback from users:
Or manually trigger feedback:

Component-Level Error Handling

Source Maps

Generate and upload source maps for better stack traces:
Configure Vite to generate source maps:
Then upload source maps using sentry-cli:

Configuration Options

Best Practices

Initialize Early

Call Sentry.init() before creating your Svelte app.

Source Maps

Always generate and upload source maps for production builds.

Store Tracking

Add breadcrumbs for store updates to understand state changes.

Context

Set user context and tags to make debugging easier.

Migration to SvelteKit

If you’re using SvelteKit, switch to the dedicated SDK:
See the SvelteKit SDK documentation for setup instructions.

Next Steps

SvelteKit

Upgrade to SvelteKit SDK for full-stack support

Source Maps

Learn how to upload source maps

Session Replay

Set up session replay

Performance

Deep dive into performance monitoring