Skip to main content
Skip to main content

Next.js

ClickStack can ingest native OpenTelemetry traces from your Next.js serverless functions in Next 13.2+.

This Guide Integrates:

  • Console Logs
  • Traces
note

If you're looking for session replay/browser-side monitoring, you'll want to install the Browser integration instead.

Installing

Enable instrumentation hook (required for v15 and below)

To get started, you'll need to enable the Next.js instrumentation hook by setting experimental.instrumentationHook = true; in your next.config.js.

Example:

Install ClickHouse OpenTelemetry SDK

Create instrumentation files

Create a file called instrumentation.ts (or .js) in your Next.js project root with the following contents:

This will allow Next.js to import the OpenTelemetry instrumentation for any serverless function invocation.

Configure environment variables

If you're sending traces directly to ClickStack, you'll need to start your Next.js server with the following environment variables to point spans towards the OTel collector:

If you're deploying in Vercel, ensure that all the environment variables above are configured for your deployment.