Build Options

Learn about the build-time configuration options available for the SvelteKit SDK.

The Sentry SvelteKit SDK supports automatic code instrumentation and source map upload during your app's build process using the sentrySvelteKit Vite plugins in your vite.config.(js|ts) file.

    sourceMapsUploadOptions.org

    Typestring

    The slug of the Sentry organization associated with the app.

    sourceMapsUploadOptions.project

    Typestring

    The slug of the Sentry project associated with the app.

    sourceMapsUploadOptions.authToken

    Typestring

    The authentication token to use for all communication with Sentry. Can be obtained from https://sentry.io/orgredirect/organizations/:orgslug/settings/auth-tokens/.

    sourceMapsUploadOptions.url

    Typestring
    Defaulthttps://sentry.io/

    The base URL of your Sentry instance. Only relevant if you're using a self-hosted or Sentry instance other than sentry.io.

    adapter

    Typestring

    By default, sentrySvelteKit will try to detect your SvelteKit adapter to configure the source maps upload correctly. If you're not using one of the supported adapters or the wrong one is detected, you can override the adapter detection using the adapter option.

    autoUploadSourceMaps

    Typeboolean

    Disable automatic source maps upload by setting autoUploadSourceMaps to false.

    The SDK primarily uses SvelteKit's hooks to collect error and performance data. However, SvelteKit doesn't yet offer a hook for universal or server-only load function calls. Therefore, the SDK uses a Vite plugin to auto-instrument load functions so that you don't have to manually add a Sentry wrapper to each function.

    Auto-instrumentation is enabled by default when you add the sentrySvelteKit() function call to your vite.config.(js|ts). However, you can customize the behavior or disable it entirely.

    autoInstrument

    Typeboolean | object
    Defaulttrue

    Set autoInstrument to false to disable auto-instrumentation of any load functions. You can still manually instrument specific load functions.

    vite.config.(js|ts)
    Copied
    import { sveltekit } from '@sveltejs/kit/vite';
    import { sentrySvelteKit } from '@sentry/sveltekit';
    
    export default {
      plugins: [
        sentrySvelteKit({
    
    autoInstrument: false;
    }), sveltekit(), ], // ... rest of your Vite config };

    Alternatively, you can provide autoInstrument with an object to customize which load functions should be instrumented.

    autoInstrument.load

    Typeboolean
    Defaulttrue

    Set to false to disable auto-instrumentation of load functions inside +page.(js|ts) or +layout.(js|ts).

    vite.config.(js|ts)
    Copied
    import { sveltekit } from "@sveltejs/kit/vite";
    import { sentrySvelteKit } from "@sentry/sveltekit";
    
    export default {
      plugins: [
        sentrySvelteKit({
    
    autoInstrument: { load: false, }, }),
    sveltekit(), ], // ... rest of your Vite config };

    autoInstrument.serverLoad

    Typeboolean
    Defaulttrue

    Set to false to disable auto-instrumentation of server-only load functions inside +page.server.(js|ts) or +layout.server.(js|ts).

    vite.config.(js|ts)
    Copied
    import { sveltekit } from "@sveltejs/kit/vite";
    import { sentrySvelteKit } from "@sentry/sveltekit";
    
    export default {
      plugins: [
        sentrySvelteKit({
    
    autoInstrument: { serverLoad: false, }, }),
    sveltekit(), ], // ... rest of your Vite config };
    Was this helpful?
    Help improve this content
    Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").