integration-react-tanstack-router-file-based

Integrate PostHog into React applications that use TanStack Router, with support for file-based route metadata. Author: PostHog. Version: 1.9.4.

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-react-tanstack-router-file-based" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-76a925248f2e510990223ed2d7717ffc5c89ca77b292b36cbd302ca68ded4d61. Verify the upstream source and version against https://skills.sh/posthog/skills/integration-react-tanstack-router-file-based 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

Integrate PostHog into React applications that use TanStack Router, with support for file-based route metadata. Author: PostHog. Version: 1.9.4.

0 Downloads

Introduction source: third_party · posthog · 1.0.0 Reference

SkillPi interpretation

Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: integration-react-tanstack-router-file-based
description: >-
  PostHog integration for React applications using TanStack Router with
  file-based routing
metadata:
  author: PostHog
  version: 1.9.4

PostHog integration for React with TanStack Router (file-based)

This skill helps you add PostHog analytics to React with TanStack Router (file-based) 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 - React with TanStack Router (file-based) example project code
  • references/tanstack-start.md - Tanstack start - 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

  • 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 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)
  • Use TanStack Router's built-in navigation events for pageview tracking instead of useEffect
  • Use PostHogProvider in the root component defined in either the file-based convention (__root.tsx) or code-based convention (wherever createRootRoute() is called) so all child routes have access to the PostHog client

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

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value75/100

Highlights

  • 提供 PostHog 与 TanStack Router 的集成方案,解决前端开发者集成分析工具的实际需求
  • 内容覆盖环境变量使用、用户识别、错误跟踪等关键集成点,实用性强
Trigger Precision90/100

Highlights

  • description 在顶层 frontmatter 中完整且清晰,准确描述了 Skill 的核心功能
  • 触发词精准,边界清晰,便于用户理解 Skill 的适用范围
Structure and Standards70/100

Areas to improve

  • 缺少 When to Use 和示例章节 Reported severity: Minor

    Skill 缺少 When to Use 章节和端到端示例,影响用户快速理解使用场景

    Recommendation: 建议补充 When to Use 章节说明适用场景,并添加端到端示例展示完整集成流程

Highlights

  • Workflow 步骤清晰,分为 4 个阶段,便于用户按顺序执行
  • 提供了详细的参考文件列表和关键原则,结构完整
Execution Reliability75/100

Areas to improve

  • 缺少不可逆操作确认机制说明 Reported severity: Minor

    Skill 未明确提及不可逆操作的确认机制,可能影响执行安全性

    Recommendation: 建议在涉及关键配置变更的步骤中添加确认机制说明,提升执行可靠性

Highlights

  • 提供了详细的集成指南和最佳实践,工具来源明确
  • 覆盖了环境变量使用、用户识别、错误跟踪等主要异常场景
Evidence Verifiability (mean of the first four)78/100

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.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

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.