File conventions

Instrumentation register

Initialize server instrumentation per instance. Use runtime-specific imports.

Formal Syntax & Structure

nextjs syntaxnextjs
instrumentation.ts: export function register(): void | Promise<void>

Working Example

Example Snippetnextjs
export async function register(){ if(process.env.NEXT_RUNTIME==='nodejs'){  const {markStart}=await import('./lib/server-marker');  markStart(); }}
Next.js Reference