Build Options

Learn about configuration options used in your Next.js configuration to control your app's build process.

The Sentry Next.js SDK supports automatic code injection and source map upload during your app's build process using the withSentryConfig wrapper in your Next.js configuration file (next.config.js or next.config.mjs). For information on updating the configuration, see Extend Next.js Configuration.

    org

    Typestring

    The slug of the Sentry organization associated with the app.

    project

    Typestring

    The slug of the Sentry project associated with the app.

    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/.

    sentryUrl

    Typestring
    Defaulthttps://sentry.io/

    The base URL of your Sentry instance. Use this if you are using a self-hosted or Sentry instance other than sentry.io.

    headers

    TypeRecord<string, string>

    Headers added to every outgoing network request.

    telemetry

    Typeboolean
    Defaulttrue

    If set to true, internal plugin errors and performance data will be sent to Sentry.

    At Sentry we like to use Sentry ourselves to deliver faster and more stable products. We're very careful of what we're sending. We won't collect anything other than error and high-level performance data. We will never collect your code or any details of the projects in which you're using this plugin.

    silent

    Typeboolean
    Defaultfalse

    Suppresses all Sentry SDK build logs.

    debug

    Typeboolean
    Defaultfalse

    Prints additional debug information about the SDK and uploading source maps when building the application.

    sourcemaps.disable

    Typeboolean

    Disable any functionality related to source maps.

    sourcemaps.assets

    Typestring | string[]

    A glob or an array of globs that specifies the build artifacts that should be uploaded to Sentry. If not specified, the plugin will try to upload all JavaScript files and source map files created during build.

    The globbing patterns follow the implementation of the glob package.

    sourcemaps.ignore

    Typestring | string[]
    Default[]

    A glob or an array of globs that specifies which build artifacts should not be uploaded to Sentry.

    sourcemaps.deleteSourcemapsAfterUpload

    Typeboolean
    Defaultfalse

    Toggle whether generated source maps within your Next.js build folder should be automatically deleted after being uploaded to Sentry.

    release.name

    Typestring

    Unique identifier for the release you want to create. Defaults to automatically detecting a value for your environment.

    release.create

    Typeboolean
    Defaulttrue

    Whether the plugin should create a release on Sentry during the build.

    release.finalize

    Typeboolean
    Defaulttrue

    Whether the Sentry release should be automatically finalized after the build ends.

    release.dist

    Typestring

    Unique identifier for the distribution, used to further segment your release. Usually your build number.

    bundleSizeOptimizations.excludeDebugStatements

    Typeboolean

    If set to true, the Sentry SDK will attempt to tree-shake any debugging code within itself during the build.

    bundleSizeOptimizations.excludeTracing

    Typeboolean

    If set to true, the Sentry SDK will attempt to tree-shake code related to tracing and performance monitoring.

    Notice: Do not enable this when using any performance monitoring-related SDK features.

    widenClientFileUpload

    Typeboolean
    Defaultfalse

    Include Next.js-internal code and code from dependencies when uploading source maps.

    Note: Enabling this option can lead to longer build times.

    autoInstrumentServerFunctions

    Typeboolean
    Defaulttrue

    Automatically instrument Next.js data fetching methods and Next.js API routes with error and performance monitoring.

    autoInstrumentMiddleware

    Typeboolean
    Defaulttrue

    Automatically instrument Next.js middleware with error and performance monitoring.

    autoInstrumentAppDirectory

    Typeboolean
    Defaulttrue

    Automatically instrument components in the app directory with error monitoring.

    tunnelRoute

    Typestring

    Tunnel Sentry requests through this route on the Next.js server, to circumvent ad-blockers blocking Sentry events from being sent. This option should be a path (for example: '/error-monitoring').

    Note: This feature only works with Next.js 11+

    automaticVercelMonitors

    Typeboolean
    Defaultfalse

    Automatically create cron monitors in Sentry for your Vercel Cron Jobs if configured via vercel.json.

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