error-tracking-nextjs

Integrate PostHog error tracking into Next.js applications with source maps.

Updated Feb 24, 2026
One-click install
npx skills add https://github.com/FrekiManagarm/dunlo --skill error-tracking-nextjs-frekimanagarm
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: error-tracking-nextjs
Source: https://github.com/FrekiManagarm/dunlo/tree/main/.agents/skills/error-tracking-nextjs
Command: npx skills add https://github.com/FrekiManagarm/dunlo --skill error-tracking-nextjs-frekimanagarm

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you capture and monitor application errors in a Next.js app using PostHog, so you can quickly identify, group, and act on issues.

Core Features & Use Cases

  • Framework-specific integration for Next.js: Covers Next.js 15.3+ instrumentation, App Router, and Pages Router setup patterns.
  • Reliable exception capture: Emphasizes enabling exception autocapture and adding manual captures at error boundaries and catch blocks.
  • Better debugging with source maps: Guides uploading source maps so stack traces resolve to original source code.

Use case example: after deploying a Next.js update, you want to ensure exceptions are grouped into actionable issues with correct stack traces, then route and investigate them using PostHog.

Quick Start

Tell the AI to integrate PostHog error tracking into your Next.js project by following the Next.js 15.3+ instrumentation-client.ts approach, adding error boundary captures, and uploading source maps for accurate stack traces.

Frequently Asked Questions about error-tracking-nextjs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add PostHog error tracking to a Next.js application?

To add PostHog error tracking to Next.js, configure PostHog with environment variables for your project token and host, enable exception autocapture in the instrumentation file, and add manual captures at error boundaries and catch blocks for comprehensive client-side and server-side monitoring.

Why do I need to upload source maps for Next.js exception tracking?

Uploading source maps for Next.js exception tracking ensures that captured stack traces resolve to your original source code rather than minified production bundles, making it significantly easier to identify, group, and debug issues quickly within PostHog.

Can I capture server-side errors in Next.js App Router and Pages Router with PostHog?

Yes, PostHog error tracking supports both the Next.js App Router and Pages Router. You can instrument request errors and error boundaries across both routing architectures to capture and group server-side and client-side exceptions effectively.

Does Next.js error tracking with PostHog support automatic exception capture?

Yes, PostHog error tracking supports automatic exception capture in Next.js. You must enable exception autocapture during the initial PostHog configuration before adding manual capture calls to ensure all unexpected errors are grouped into actionable issues.

What is the best way to configure PostHog in Next.js 15.3+ for error tracking?

The best way to configure PostHog error tracking in Next.js 15.3+ is by using the instrumentation-client.ts approach. This allows you to initialize PostHog with environment variables, enable exception autocapture, and set up source map uploads for accurate stack traces.

Why are my PostHog stack traces showing minified code instead of original source in Next.js?

Minified stack traces in PostHog appear when source maps are not uploaded. You must upload source maps during your Next.js build process so PostHog can resolve the minified production errors back to your original source code for faster debugging.