integration-nextjs-app-router
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "integration-nextjs-app-router" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-2aac4d9c3e0520f0db4ee9058d3cba2a8a92c56b4fff49c3a51d128ffab67529. Verify the upstream source and version against https://skills.sh/posthog/skills/integration-nextjs-app-router before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skills.sh
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
PostHog integration for Next.js App Router applications.
Introduction source: third_party · posthog · 1.0.0 Reference
SkillPi interpretation
- Tasks
- PostHog integration for Next.js App Router applications
- Testing
- Not tested
Browse files
Frontmatter
name: integration-nextjs-app-router
description: PostHog integration for Next.js App Router applications
metadata:
author: PostHog
version: 1.9.4PostHog 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:
basic-integration-1.0-begin.md- PostHog Setup - Begin ← Start herebasic-integration-1.1-edit.md- PostHog Setup - Editbasic-integration-1.2-revise.md- PostHog Setup - Revisebasic-integration-1.3-conclude.md- PostHog Setup - Conclusion
Reference files
references/EXAMPLE.md- Next.js App Router example project codereferences/next-js.md- Next.js - docsreferences/identify-users.md- Identify users - docsreferences/basic-integration-1.0-begin.md- PostHog setup - beginreferences/basic-integration-1.1-edit.md- PostHog setup - editreferences/basic-integration-1.2-revise.md- PostHog setup - revisereferences/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
- Environment variables: Always use environment variables for PostHog keys. Never hardcode them.
- Minimal changes: Add PostHog code alongside existing integrations. Don't replace or restructure existing code.
- Match the example: Your implementation should follow the example project's patterns as closely as possible.
Framework guidelines
- For Next.js 15.3+, initialize PostHog in instrumentation-client.ts for the simplest setup
- For feature flags, use useFeatureFlagEnabled() or useFeatureFlagPayload() hooks - they handle loading states and external sync automatically
- Add analytics capture in event handlers where user actions occur, NOT in useEffect reacting to state changes
- Do NOT use useEffect for data transformation - calculate derived values during render instead
- Do NOT use useEffect to respond to user events - put that logic in the event handler itself
- Do NOT use useEffect to chain state updates - calculate all related updates together in the event handler
- Do NOT use useEffect to notify parent components - call the parent callback alongside setState in the event handler
- To reset component state when a prop changes, pass the prop as the component's key instead of using useEffect
- useEffect is ONLY for synchronizing with external systems (non-React widgets, browser APIs, network subscriptions)
Identifying users
Identify users during login and signup events. Refer to the example code and documentation for the correct identify pattern for this framework. If both frontend and backend code exist, pass the client-side session and distinct ID using X-POSTHOG-DISTINCT-ID and X-POSTHOG-SESSION-ID headers to maintain correlation.
Error tracking
Add PostHog error tracking to relevant files, particularly around critical user flows and API boundaries.
Current listing version
1.0.0
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 Next.js App Router 应用中集成 PostHog 分析工具的能力,具有明确的实用价值
- 覆盖了环境变量使用、用户识别、错误跟踪等关键集成点
Highlights
- description 明确描述了 Skill 的功能,触发词精准完整
Areas to improve
-
缺少 When to Use 章节 Reported severity: Minor
Skill 文档中缺少 When to Use 章节,用户无法快速了解适用场景
Recommendation: 建议添加 When to Use 章节,说明该 Skill 的适用场景和使用时机
-
缺少端到端示例章节 Reported severity: Minor
Skill 文档中缺少端到端的完整示例,用户可能难以理解完整流程
Recommendation: 建议添加端到端示例章节,展示从开始到结束的完整集成流程
Highlights
- 结构清晰,包含 Workflow、Reference files、Key principles 等多个章节
- frontmatter 完整,步骤划分明确,有出口条件
Highlights
- 提供了详细的集成步骤和参考文件,工具来源明确
- 覆盖了主要异常情况,如环境变量使用和错误跟踪
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.