Skip to content

Next.js

Server-side Instrumentation

Vercel provides a comprehensive OpenTelemetry integration through the @vercel/otel package. After following Vercel’s integration instructions, add the following environment variables to your project:

Terminal
OTEL_EXPORTER_OTLP_ENDPOINT=https://logfire-api.pydantic.dev
OTEL_EXPORTER_OTLP_HEADERS='Authorization=your-write-token'

This configuration directs the OpenTelemetry instrumentation to send data to Logfire.

A working example can be found in the examples/nextjs directory.

Client-side Instrumentation

Client-side instrumentation can be implemented using the @pydantic/logfire-browser package. To set it up, you need to complete the following steps:

A complete working example can be found in the examples/nextjs-client-side-instrumentation directory.