integration-nextjs-app-router

Document client- and server-side PostHog events for Next.js App Router projects.

8|12|Updated Dec 9, 2025
One-click install
npx skills add https://github.com/NEAR-DevHub/trezu --skill integration-nextjs-app-router-near-devhub
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: integration-nextjs-app-router
Source: https://github.com/NEAR-DevHub/trezu/tree/main/.agents/skills/integration-nextjs-app-router
Command: npx skills add https://github.com/NEAR-DevHub/trezu --skill integration-nextjs-app-router-near-devhub

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Enables unified analytics for Next.js App Router apps by providing client and server tracking, user identification, error tracking, and feature flag usage through PostHog.

Core Features & Use Cases

  • Client-side event capture after login and page interactions
  • Server-side event logging for API routes and server actions using posthog-node
  • Clear guidelines and references to implement analytics across the app

Quick Start

Initialize PostHog in instrumentation-client.ts and begin instrumenting client and server events following the provided references.

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 implement PostHog analytics in a Next.js App Router project?

Implement PostHog analytics by initializing the client in instrumentation-client.ts, then use posthog-node to log server-side API route events and capture client-side interactions for unified tracking.

Can I track server-side events with PostHog in Next.js server components?

Yes, you can track server-side events in Next.js server components and API routes using posthog-node, ensuring backend actions are logged alongside client interactions for comprehensive analytics.

What is the best way to identify users and track errors with PostHog in Next.js?

The best way to identify users and track errors is by following consistent event naming guidelines and references, capturing user logins client-side and logging errors through PostHog tracking.

Does PostHog work with Next.js App Router for both client-side and server-side tracking?

Yes, PostHog works with Next.js App Router by supporting client-side event capture after page interactions and server-side event logging for API routes and server actions.

Do I need feature flag guidelines for PostHog integration in Next.js?

Yes, PostHog integration includes feature flag usage guidelines, providing references to implement analytics end-to-end with consistent event naming and user identification across your application.