Monitoring & Observability
Set up production monitoring for Next.js — Core Web Vitals, error tracking, logging, performance monitoring, and the observability stack used in enterprise applications.
Last reviewed: January 2025
🔍 What Is It?
Production monitoring for Next.js has three layers:
- Core Web Vitals — LCP, CLS, INP, FID measured on real user devices
- Vercel Analytics (built-in), Google Search Console, Lighthouse CI
- Error tracking — catch and alert on exceptions in real-time
- Sentry (most popular), Datadog, Bugsnag
- Server observability — logs, traces, metrics for Route Handlers and SSR
- Vercel Logs, Datadog APM, OpenTelemetry
🎯 Why Do We Need It?
Without monitoring:
- →You learn about errors from users, not dashboards
- →Performance regressions go unnoticed until users complain
- →Debugging production issues is guesswork
With monitoring:
- →Errors are caught and alerted within seconds
- →Performance regressions are detected before users notice
- →Production debugging uses real data, not assumptions
🏗️ What Happens in Real Projects?
Monitoring stack for a production SaaS:
- →Vercel Analytics — Core Web Vitals, page views, geography
- →Sentry — JavaScript errors, server errors, performance traces
- →Datadog — infrastructure metrics, custom business metrics
- →Axiom — structured log search and dashboards
- →Checkly — synthetic monitoring (run Playwright tests every 5 minutes)
⚙️ How It Works
Core Web Vitals measurement:
Next.js exposes a reportWebVitals function in the root layout or via the useReportWebVitals hook. It receives real user measurements and you send them to your analytics platform.
Error tracking with Sentry:
- →Sentry SDK wraps Server Components, Route Handlers, and Client Components
- →Unhandled errors are captured with full stack trace and context
- →Errors are grouped by similarity and assigned to team members
💻 Example
Sentry and Web Vitals Setup — Production monitoring setup for a Next.js application.
🤔 Common Confusions
❓ Is Vercel Analytics enough or do I need Sentry too?
They serve different purposes. Vercel Analytics measures user experience (Core Web Vitals, page views). Sentry catches and alerts on errors. You need both. Vercel Analytics tells you your LCP is slow; Sentry tells you your checkout is throwing a 500 error for 5% of users.
❓ How do I monitor Server Component errors?
Sentry's Next.js SDK automatically captures Server Component errors. Add error.tsx boundaries at each route level — Sentry captures the error before the boundary handles it. Also configure Sentry in sentry.server.config.ts for server-side error capture.
❓ What is the difference between LCP and FCP?
FCP (First Contentful Paint) is when any content first appears. LCP (Largest Contentful Paint) is when the main content (usually the hero image or heading) appears. LCP is the more important metric — it measures when users can see the primary content. Google's threshold: LCP < 2.5s is good.
🚨 Common Production Issues
Sentry capturing too many errors — noisy alerts cause alert fatigue. Configure ignoreErrors for known browser quirks and network errors. Set sampleRate: 0.1 for performance transactions to reduce costs.
Web Vitals not improving despite optimisations — Lab metrics (Lighthouse) and field metrics (real user data) can differ significantly. Always measure field metrics (Vercel Analytics, CrUX) — they reflect real user experience on real devices.
Missing source maps in Sentry — without source maps, Sentry shows minified stack traces that are impossible to debug. Configure Sentry's Webpack plugin to upload source maps during builds.
✅ Best Practices
Set up Sentry before going to production — not after the first incident
Upload source maps to Sentry — minified stack traces are useless
Set up alerts for error rate spikes, not just individual errors
Monitor Core Web Vitals after every production deployment
Use structured logging (JSON) for server logs — enables log search and dashboards
🏛️ Architect's Note
Observability is not optional for production systems. The minimum viable monitoring stack for a Next.js app: Sentry (errors) + Vercel Analytics (Web Vitals) + structured logging. Add APM (Datadog, Datadog) when you need to trace slow requests across multiple services.
💬 Frequently Asked Questions
🎯 Key Takeaways
🔗 Related Topics
🎯 Practice this topic in interviews
↗ Where this topic fits
Next.js Technology Guide
Return to the Next.js learning hub.
Frontend Engineer Career Path
A beginner-friendly journey through web foundations, React, production frontend engineering, and interview preparation.
Full Stack Java Developer Career Path
A guided route through frontend foundations, Java backend engineering, delivery workflows, and interview readiness.
Sources
Sources / References
Use these Next.js references to verify the concept in official docs and continue into the most relevant SplashRide pages.
Official documentation
Related SplashRide pages
SplashRide Next.js learning path
Browse the full Next.js topic collection and learning order on SplashRide.
Next.js Interview Prep
Practice Next.js interview questions and scenario-based answers.
Frontend Engineer Career Path
A beginner-friendly journey through web foundations, React, production frontend engineering, and interview preparation.
Full Stack Java Developer Career Path
A guided route through frontend foundations, Java backend engineering, delivery workflows, and interview readiness.
Vercel Deployment
Deploy Next.js to Vercel — zero-config deployments, preview environments, edge functions, analytics, and the production configuration patterns used in enterprise.
CI/CD Pipelines
Set up production-grade CI/CD for Next.js — GitHub Actions, automated testing, type checking, preview deployments, and zero-downtime production releases.