Blog/Next.js Observability: App Router to Edge
Observability

Next.js Observability: App Router to Edge

Next.js is used by 52.9% of React developers yet ships almost no per-route visibility. Track routes, edge errors, TTFB, and real-user Web Vitals from one key.

MS
Merse Sárvári, Founder, Statvisor
14 July 2026 · 8 min read

TL;DR

Next.js runs on three runtimes, Node, edge, and the browser, and each fails differently. Wrap App Router handlers with sv.route(), drop StatvisorAnalytics into the layout, and watch server latency, edge errors, and real-user Web Vitals on one timeline.

Next.js blurs the line between frontend and backend, which is exactly why it is so easy to fly blind. A server action, an edge middleware, a route handler, and a client component all ship together, and a slowdown in any of them lands on the same user. Default tooling shows you almost none of it.

Why Does Next.js Need Per-Runtime Monitoring?

52.9%
of React developers build on Next.js
2.5s
the LCP line Google grades as good
75th %ile
of real users is how Google scores the page

The same app runs on the Node runtime, the edge runtime, and the browser. Each fails differently. When we instrumented an edge middleware that threw in a single region, it stayed invisible to our Node-based monitor until we watched it per runtime.

RuntimeTypical failureHow it's captured
Node route handlersA slow database call, 500ssv.route() wrapping every method
Edge middlewareA region-specific throwError rate per route from real traffic
BrowserPoor LCP or INPStatvisorAnalytics field data
Three runtimes, three failure modes, one deploy.
Laptop showing a Next.js project with terminal output
Server, edge, and client all ship together, and break separately.

How Do You Monitor App Router Handlers?

Wrap your route handlers once and every method reports latency and errors, the same per-route P95 and P99 view explained in P50 vs P95 vs P99. Delivery runs after the response via Next's after(), so it adds no time to the request:

typescript
// lib/statvisor.ts
import { Statvisor } from "@statvisor/sdk";
export const sv = new Statvisor({ apiKey: process.env.STATVISOR_API_KEY! });

// app/api/orders/route.ts
import { NextResponse } from "next/server";
import { sv } from "@/lib/statvisor";

export const { GET } = sv.route("/api/orders", {
  GET: async () => NextResponse.json({ orders: [] }),
});

Track Web Vitals From Real Visitors

Lab scores lie about the visitor on hotel wifi. Drop the analytics component into your root layout to measure LCP, CLS, INP, and TTFB from actual traffic:

typescript
// app/layout.tsx
import { StatvisorAnalytics } from "@statvisor/sdk/react";

export default function RootLayout({ children }) {
  return (
    <html><body>
      {children}
      <StatvisorAnalytics frontendKey="vl_fe_..." />
    </body></html>
  );
}
Dashboard showing LCP, CLS, INP and TTFB collected from real Next.js sessions
Field data from real sessions is the version Google trusts.

Statvisor tracks App Router handlers and real-user Web Vitals from one key, so a slow TTFB on the edge and a failing LCP in the browser sit on the same timeline.

Close the Remaining Gaps

Instrumentation is step one, but Next.js hides traps a naive setup still misses. Server actions run on the server yet never hit a route handler, so they slip past per-route timing unless you wrap them. Edge middleware can throw in a single region and stay invisible to a Node-based monitor. And a genuinely fast API can still fail Core Web Vitals if the client render is heavy. Close each in turn: start with the four blind spots in Next.js API routes: the monitoring blind spots, connect backend latency to the frontend score in how slow API routes kill your Core Web Vitals, and learn to read the numbers in P50 vs P95 vs P99.

Ready to monitor your API in production?

Statvisor gives you latency percentiles, error rates, and request volume for every route, in minutes, not days.

Get started free →
MS

Written by

Merse Sárvári, Founder, Statvisor

Merse builds Statvisor and has spent years instrumenting JavaScript APIs and frontends for solo products and small teams.

Every post is written from hands-on experience building and running JavaScript apps, and reviewed for accuracy before publishing.