integration-nextjs-app-router

Integrate PostHog analytics into Next.js App Router applications.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you reliably integrate PostHog product analytics into Next.js App Router apps so you can capture events, identify users, and track errors with correct client/server correlation.

Core Features & Use Cases

  • Event tracking plan & implementation: Guide creation of an event tracking strategy and placement of capture() calls in high-value action handlers (not pageviews).
  • User identification for correlation: Define when and how to call identify() during login/signup so events map to the right person across sessions.
  • Next.js App Router server-side instrumentation: Ensure required server-side events are added for API route boundaries, using environment variables and matching distinct IDs.
  • Error tracking: Add exception capture around critical flows and API boundaries for actionable observability.

Quick Start

Ask the agent to follow the PostHog Next.js App Router integration workflow starting with basic-integration-1.0-begin.md and implement the remaining phases until the analytics dashboard report is produced.

Frequently Asked Questions about integration-nextjs-app-router

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

FAQPage Schema
How do I integrate PostHog analytics into a Next.js App Router application?

To integrate PostHog analytics into a Next.js App Router application, you implement client-side capture and identify calls alongside required server-side event tracking for API route boundaries, ensuring events map to the correct distinct ID across domains.

How do I track user identity across sessions in Next.js App Router?

Track user identity in Next.js App Router by calling identify() during login and signup flows, which maps captured events to the right person across sessions and ensures correct client/server correlation.

What is the best way to capture server-side events in Next.js API routes with PostHog?

The best way to capture server-side events in Next.js API routes is to add capture() calls at API route boundaries using environment variables for PostHog configuration while matching the user's distinct ID across domains.

How do I track errors and exceptions in Next.js App Router using PostHog?

Track errors in Next.js App Router using PostHog by adding exception capture around critical user flows and API boundaries, providing actionable observability for application failures.

Does PostHog event tracking work with Next.js App Router server-side rendering?

Yes, PostHog event tracking works with Next.js App Router by defining a tracking plan for high-value actions and implementing required server-side captures for API route boundaries using environment variables for configuration.

When should I capture PostHog events in Next.js App Router applications?

Capture PostHog events in Next.js App Router applications by placing capture() calls in high-value action handlers rather than pageviews, specifically targeting authentication endpoints, user login/signup flows, and feature flag usage.