error-tracking-nextjs

Integrate PostHog error tracking into Next.js App Router and Pages Router applications.

58|5|Updated Jan 19, 2026
One-click install
npx skills add https://github.com/PostHog/skills --skill error-tracking-nextjs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: error-tracking-nextjs
Source: https://github.com/PostHog/skills/tree/main/skills/posthog/all/skills/error-tracking-nextjs
Command: npx skills add https://github.com/PostHog/skills --skill error-tracking-nextjs

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Integrates PostHog error tracking into Next.js applications to provide visibility into runtime errors, performance issues, and user-impacting failures without heavy refactoring of existing error handling.

Core Features & Use Cases

  • Automatic error autocapture: Enables automatic capture of unhandled exceptions in Next.js apps.
  • Cross-router support: Works with both App Router and Pages Router implementations.
  • Server and client monitoring: Provides guidance and instrumentation for frontend and backend error tracking, including source maps and external integrations.
  • Config-driven security: Encourages environment-variable configuration and minimal code changes to existing error handling.

Quick Start

Install and initialize the PostHog client in your Next.js project following the App Router or Pages Router instructions, then verify errors appear in PostHog.

Frequently Asked Questions about error-tracking-nextjs

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

FAQPage Schema
How do I integrate PostHog error tracking into a Next.js application?

PostHog error tracking captures unhandled runtime exceptions across both client-side and server-side Next.js environments, providing visibility into performance issues and user-impacting failures without requiring heavy refactoring of your existing error handling logic.

Does PostHog error tracking work with both App Router and Pages Router in Next.js?

PostHog provides dedicated guidance and instrumentation for both frontend and backend error tracking in Next.js, including server-side monitoring, client-side error capture, source maps, and external integrations for comprehensive cross-context visibility.

Why does my Next.js PostHog setup require environment variables for error monitoring?

Your Next.js PostHog setup requires environment variables for error monitoring to ensure config-driven security, allowing minimal code changes to existing error handling while safely managing API keys across server and client environments.

Can I add PostHog error tracking without disrupting my existing Next.js error handling?

Yes, you can add PostHog error tracking without disrupting existing Next.js error handling, as the integration is designed to be non-disruptive and requires only minimal code changes to start capturing runtime errors automatically.

What is the best way to monitor server-side runtime errors in Next.js with PostHog?

The best way to monitor server-side runtime errors in Next.js with PostHog is to follow the provided server-side instrumentation guidance, which enables automatic capture of backend exceptions and performance issues directly within your existing application architecture.