register()

The function exported from instrumentation.ts that Next.js calls once when a new server instance starts.

In more detail

Use it to start the OpenTelemetry SDK or other monitoring. Check process.env.NEXT_RUNTIME to import Node-only code only in the Node.js runtime.

Example

export async function register() {
  if (process.env.NEXT_RUNTIME === 'nodejs') await import('./instrumentation.node');
}

Related terms

Taught in

References