integration-nextjs-pages-router

Instrument event-level analytics in Next.js Pages Router apps with PostHog.

Updated Mar 21, 2026
One-click install
npx skills add https://github.com/dallasbpeters/tandra-peters-consulting --skill integration-nextjs-pages-router
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: integration-nextjs-pages-router
Source: https://github.com/dallasbpeters/tandra-peters-consulting/tree/main/.claude/skills/integration-nextjs-pages-router
Command: npx skills add https://github.com/dallasbpeters/tandra-peters-consulting --skill integration-nextjs-pages-router

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Provide a structured, minimal-risk method to instrument and consume analytics in Next.js Pages Router apps using PostHog, enabling actionable insights without major refactors.

Core Features & Use Cases

  • Client-side event tracking in Next.js Pages Router apps using PostHog's instrumentation points (e.g., instrumentation-client.ts) to capture user actions and feature usage.
  • Server-side event capture via API routes or server utilities to ensure critical business operations are logged and correlated with user identity.
  • Best practices for identifying users, error tracking, and aligning analytics with the Next.js Pages Router workflow.

Quick Start

Follow the workflow steps in this SKILL.md to enable PostHog in a Next.js Pages Router project and begin capturing key events and errors.

Frequently Asked Questions about integration-nextjs-pages-router

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

FAQPage Schema
How do I track custom events in Next.js Pages Router using PostHog?▼

PostHog event tracking in Next.js Pages Router involves using instrumentation-client.ts for client-side user actions and API routes for server-side business events, focusing on key actions rather than just pageviews.

What is the best way to identify users in PostHog across client and server boundaries in Next.js?▼

User identification in PostHog across Next.js boundaries requires passing distinct user IDs through both instrumentation-client.ts and server-side API routes to maintain consistent event correlation and accurate identity tracking.

Does this PostHog instrumentation method require a major refactor for existing Next.js Pages Router apps?▼

No, this PostHog instrumentation method is designed as a structured, minimal-risk approach that enables actionable analytics insights in Next.js Pages Router apps without requiring major refactors to the existing codebase.

Can I capture server-side analytics events in Next.js API routes with PostHog?▼

Yes, server-side event capture in Next.js API routes with PostHog is fully supported, allowing you to log critical business operations and correlate them with user identity alongside client-side event tracking.

How do I handle error tracking with PostHog in a Next.js Pages Router application?▼

Error tracking with PostHog in Next.js Pages Router involves capturing exceptions across both client-side instrumentation-client.ts and server-side API routes, ensuring errors are logged and correlated with user identity for comprehensive monitoring.