Skip to content

Using Spotlight with SvelteKit

This guide gets Spotlight up and running in SvelteKit with Sentry. You don’t strictly need Sentry for Spotlight to work, we highly recommend it.

Install Sentry

Follow the Sveltekit Getting Started guide on Sentry to install and configure Sentry.

Install Spotlight

Install the Spotlight package:

Terminal window
npm add @spotlightjs/spotlight

Initialize Spotlight after Sentry and start the Sidecar on the server. Just add a little code to your SvelteKit hooks files:

hooks.client.js
import * as Sentry from '@sentry/sveltekit';
import * as Spotlight from '@spotlightjs/spotlight';
Sentry.init({
dsn: '___DSN___',
tracesSampleRate: 1.0,
// ...your Sentry options
});
export const handleError = Sentry.handleErrorWithSentry();
if (import.meta.env.DEV) {
Spotlight.init({
injectImmediately: true,
});
}

That’s it! Check out the Configuration to further customize Spotlight.