posthog avatar

Integration Nextjs App Router

This walks you through integrating PostHog analytics into a Next.js App Router project with a four-step workflow that handles setup, editing, revision, and conclusion. It comes with reference docs and an example project showing the target implementation pattern. The guidance is opinionated in good ways: it pushes you toward instrumentation-client.ts for Next.js 15.3+, reminds you to use environment variables, and includes surprisingly detailed React advice about avoiding useEffect for things that aren't actually external system synchronization. If you're adding PostHog to a Next.js app and want to follow their recommended patterns without hunting through docs, this gives you a structured path.

skills.sh installs
316
GitHub stars
79
last updated
Aug 21, 2026

Install

$ npx -y skills add posthog/skills --skill integration-nextjs-app-router --agent claude-code

Installs into .claude/skills of the current project.

Files

PostHog integration for Next.js App Router

This skill helps you add PostHog analytics to Next.js App Router applications.

Workflow

Follow these steps in order to complete the integration:

  1. basic-integration-1.0-begin.md - PostHog Setup - Begin ← Start here
  2. basic-integration-1.1-edit.md - PostHog Setup - Edit
  3. basic-integration-1.2-revise.md - PostHog Setup - Revise
  4. basic-integration-1.3-conclude.md - PostHog Setup - Conclusion

Reference files

  • references/EXAMPLE.md - Next.js App Router example project code
  • references/next-js.md - Next.js - docs
  • references/identify-users.md - Identify users - docs
  • references/basic-integration-1.0-begin.md - PostHog setup - begin
  • references/basic-integration-1.1-edit.md - PostHog setup - edit
  • references/basic-integration-1.2-revise.md - PostHog setup - revise
  • references/basic-integration-1.3-conclude.md - PostHog setup - conclusion

The example project shows the target implementation pattern. Consult the documentation for API details.

Key principles

Sponsors

Details

Repository
github.com/posthog/skills
Category
Frontend Development
First seen
Jun 3, 2026

More from posthog/skills

All 6
1wsimmonds avatarnextjs-use-search-params-suspensewsimmonds/claude-nextjs-skillsPattern for using useSearchParams hook with Suspense boundary in Next.js. Covers the required combination of 'use client' directive and Suspense wrapper when ac313skills.sh installs
2wsimmonds avatarnextjs-pathname-id-fetchwsimmonds/claude-nextjs-skillsFocused pattern for fetching data using URL parameters in Next.js. Covers creating dynamic routes ([id], [slug]) and accessing route parameters in server compon296skills.sh installs
3wix avatarwix-cli-site-widgetwix/skillsUse when building interactive widgets, custom data displays, or configurable site components with settings panels. Triggers include widget, custom element, inte288skills.sh installs
4tech-leads-club avatarperf-astrotech-leads-club/agent-skillsAstro-specific performance optimizations for 95+ Lighthouse scores. Covers critical CSS inlining, compression, font loading, and LCP optimization. Use when opti286skills.sh installs
5patricio0312rev avatarreact-server-componentspatricio0312rev/skillsImplements React Server Components (RSC) patterns with Next.js App Router including data fetching, streaming, selective hydration, and server/client composition284skills.sh installs
6gentleman-programming avatartailwind-4gentleman-programming/gentleman-skillsTailwind CSS 4 patterns and best practices. Trigger: When styling with Tailwind - cn(), theme variables, no var() in className.279skills.sh installs