Next.js monitoring for server and browser
by Obseria · Frontend, mobile and e-commerce- OpenTelemetry
- Digital Experience
- Frontend, mobile and e-commerce
- Category
- Frontend, mobile and e-commerce
- Key metrics
- 8
- Ready-made
- 5 dashboards & alerts
- Setup
- 3 steps
- Standard
- OTLP
With instrumentation.ts and the OpenTelemetry SDK, Obseria traces every Next.js route, API route, server fetch and database call, adds browser traces from the client, and connects both into one view.
Built on the official hook
Next.js calls register() from instrumentation.ts on startup. Obseria uses this documented hook, so no custom server or wrapper is needed.
Server and client together
Server rendering and API routes come from the Node.js SDK, page loads and fetch calls from the browser SDK, all in the same trace view.
Releases you can compare
Tag service.version per deploy and compare route latency and errors before and after each release.
Obseria interface



Ready the moment data arrives
- Next.js routes with RED metrics per route
- Slowest Server Components and route handlers
- Alert on error rate per route after a deploy
- Alert on Node.js event loop delay
- Core Web Vitals per page next to server latency
What Obseria monitors in a Next.js app
App Router and Pages Router
Next.js emits its own spans for request handling and rendering, with attributes such as next.route and next.span_type.
Route handlers and API routes
Every API call becomes a server span with method, route and status code.
Server-side fetch
fetch calls in Server Components and route handlers appear as client spans and propagate trace context downstream.
Databases and caches
The Node.js auto-instrumentations cover pg, mysql, MongoDB, Redis and more, so slow queries show up inside the request.
Browser
instrumentation-client.ts adds document load, fetch and interaction spans from real users.
Node.js runtime
Event loop, garbage collection and heap metrics show whether the server process itself is the bottleneck.
The Next.js signals that matter
Obseria collects these values automatically and shows them in ready-made dashboards and alerts.
| Metric | Unit | What it tells you |
|---|---|---|
BaseServer.handleRequest | ms | Span, not a metric: the top-level span Next.js creates per incoming request, with http.method, http.status_code and next.route. |
AppRender.getBodyResult | ms | Span, not a metric: server rendering of an App Router page, the place where slow Server Components show up. |
AppRouteRouteHandlers.runHandler | ms | Span, not a metric: execution of an App Router route handler (route.ts). |
AppRender.fetch | ms | Span, not a metric: a fetch call made while rendering, including its cache behaviour. |
http.server.request.duration | s | Latency histogram of inbound HTTP requests from the HTTP instrumentation, when stable HTTP semantic conventions are enabled. |
nodejs.eventloop.delay.p99 | s | 99th percentile event loop delay; high values mean CPU-bound work blocks other requests. |
v8js.gc.duration | s | Duration of garbage collection runs per GC type. |
v8js.memory.heap.used | By | Used V8 heap per heap space, to spot memory growth in long-running servers. |
Set up Next.js monitoring in minutes
- 1
Install the packages
npm install the OpenTelemetry Node SDK with auto-instrumentations and OTLP exporters, plus the web SDK packages for the browser.
- 2
Add instrumentation.ts
Create instrumentation.ts and instrumentation.node.ts at the project root; the SDK only loads in the Node.js runtime, so Edge routes keep building.
- 3
Add browser tracing
On Next.js 15.3+ put the web tracer in instrumentation-client.ts; on older versions use a client component rendered once by the root layout.
// instrumentation.ts (project root) — Next.js calls register() on startup
export async function register() {
if (process.env.NEXT_RUNTIME === "nodejs") {
await import("./instrumentation.node"); // keeps Edge builds working
}
}
// instrumentation.node.ts — server side: routes, API routes, fetch, database calls
import { NodeSDK } from "@opentelemetry/sdk-node";
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
import { resourceFromAttributes } from "@opentelemetry/resources";
const headers = { Authorization: "Bearer ${OBSERIA_TOKEN}" };
new NodeSDK({
resource: resourceFromAttributes({ "service.name": "my-next-app" }),
traceExporter: new OTLPTraceExporter({ url: "${OBSERIA_OTLP_ENDPOINT}/v1/traces", headers }),
metricReader: new PeriodicExportingMetricReader({
exporter: new OTLPMetricExporter({ url: "${OBSERIA_OTLP_ENDPOINT}/v1/metrics", headers }),
}),
instrumentations: [getNodeAutoInstrumentations()],
}).start();
// instrumentation-client.ts (Next.js 15.3+) — browser side, same WebTracerProvider
// as the React setup with service.name "my-next-app-web"
// Next.js 14 only: set experimental.instrumentationHook = true in next.config.tsWhy Next.js monitoring matters
Next.js blurs the line between frontend and backend. A single page can be rendered on the server, stream Server Components, call route handlers, fetch from internal APIs, read from a database and then hydrate in the browser. When that page is slow, the cause can sit in any of those steps. Next.js monitoring has to see both sides, the Node.js server and the browser, and connect them, otherwise teams end up guessing whether the problem is rendering, data fetching or the client.
Next.js has first-class OpenTelemetry support. The framework calls register() from instrumentation.ts when the server starts, and it emits its own spans for request handling, rendering and fetch once a tracer is registered. Obseria builds on this documented hook with the standard OpenTelemetry Node.js SDK on the server and the web SDK in the browser. Teams that deploy on Vercel can also use @vercel/otel, which sends to any OTLP endpoint.
Signals that matter for Next.js performance monitoring
- Request handling: the
BaseServer.handleRequestspan carries route and status code for every request and is the root of each server trace. - Rendering:
AppRender.getBodyResultshows how long server rendering takes. Child spans reveal the Server Component or data call that holds it up. - Route handlers:
AppRouteRouteHandlers.runHandlermeasures API logic inroute.tsfiles separately from rendering. - Data fetching:
AppRender.fetchand the database spans from the Node.js auto-instrumentations show which upstream call or query dominates. - Runtime:
nodejs.eventloop.delay.p99,v8js.gc.durationandv8js.memory.heap.usedshow whether the server process is overloaded. - Browser: document load, fetch and interaction spans from
instrumentation-client.tsshow what users experience after hydration.
By default Next.js emits a focused set of spans. Setting NEXT_OTEL_VERBOSE=1 adds more detail when you need to dig into rendering internals.
Common Next.js problems and how to detect them
Slow server rendering
A Server Component that awaits a slow API blocks the whole response. In the trace, a long AppRender.getBodyResult span with one long child fetch span shows exactly which call to cache, parallelize or move behind a Suspense boundary.
Sequential data fetching
Awaiting one fetch after another in a layout and its page creates a waterfall on the server. Child spans that start only after the previous one ended make the pattern visible.
Unexpected cache misses
A fetch that should be cached but runs on every request increases latency and load on the backend. The fetch spans per route show how often the upstream call actually happens.
Event loop blocking
Heavy JSON processing or synchronous work in a route handler blocks every concurrent request on that instance. Rising event loop delay together with higher latency across many routes points to this cause.
Regressions after a deploy
A new release can make one route slower without any error. Comparing latency and error rate per service.version separates real regressions from noise.
Best practices for Next.js instrumentation
- Load the Node.js SDK only when
NEXT_RUNTIMEisnodejs, so Edge bundles do not try to include Node.js modules. - Use separate service names for server and browser, for example
my-next-appandmy-next-app-web, so both sides are easy to filter. - Set
service.versionfrom your commit or build ID to compare releases. - Allow the
traceparentheader on your API routes so browser and server spans join one trace. - Use a token scoped to ingest only for the browser part; it is visible in the client bundle.
- Enable
NEXT_OTEL_VERBOSEtemporarily for deep debugging rather than permanently, to keep span volume focused.
How Obseria helps with Next.js monitoring
Obseria receives Next.js server traces, Node.js runtime metrics and browser traces over OTLP. TopoGraph maps the Next.js app to the APIs and databases it calls. Server spans and browser spans meet in one trace view, so you can follow a click from the browser through rendering and route handlers down to the SQL query. Dashboards, alerts and SLOs are included, deployment tracking marks each release, and Obseria Intelligence correlates latency spikes with the deploy, query or dependency behind them.
Learn more
What is OpenTelemetry?
What is OpenTelemetry? Learn how OTel's APIs, SDKs, Collector, OTLP and semantic conventions produce vendor-neutral traces, metrics, logs and profiles.
What is APM (application performance monitoring)?
What is APM? Learn how application performance monitoring measures latency, throughput and errors, how distributed tracing works, and which metrics matter.
Next.js monitoring FAQ
Both send standard OTLP. @vercel/otel is a compact option that also works on Vercel and in the Edge runtime. The NodeSDK with auto-instrumentations-node covers more libraries, such as database drivers, on self-hosted Node.js servers. Obseria accepts either.
Yes. Next.js emits spans for both routers once a tracer is registered, and the Node.js auto-instrumentations cover the HTTP server and outbound calls in either case.
Next.js 15 and newer load instrumentation.ts automatically. Next.js 14 needs experimental.instrumentationHook in next.config.ts. instrumentation-client.ts for the browser is available from 15.3; before that, use a client component in the root layout.
The NodeSDK only runs in the Node.js runtime, which is why register() checks NEXT_RUNTIME. For tracing Edge code, @vercel/otel supports the Edge runtime.
Yes, if you add the Web Vitals module from the React setup to the client side. The values arrive as web_vitals.* metrics per page next to your server latency.
Start monitoring Next.js today
Connect Next.js in minutes with OpenTelemetry or the Obseria Agent. Free for 14 days.