Limited Server Tracing

Learn how to set up the Nuxt SDK with limited server tracing by adding a top-level import to the build output.

Sentry needs to be initialized before the rest of the application runs. If the default way of adding an --import CLI flag doesn't work for you, enable the SDK to add a top-level import.

The automatically added top-level import will then import the Sentry server-side config at the top of the Nuxt server entry file. In this case, Sentry isn’t initialized before the app starts, but is set up as early as possible.

Enable the top-level import by setting autoInjectServerSentry:

nuxt.config.ts
Copied
export default defineNuxtConfig({
  sentry: {
    autoInjectServerSentry: "top-level-import",
  },
});

By default, the SDK will add the Sentry server config to the build output (typically, .output/server/sentry.server.config.mjs). The SDK will then automatically import this file at the top of the Nitro server entry file in the build output.

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").