integration-react-react-router-7-declarative

Integrate PostHog analytics into React Router v7 declarative mode applications.

58|5|Updated Jan 19, 2026
One-click install
npx skills add https://github.com/PostHog/skills --skill integration-react-react-router-7-declarative
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: integration-react-react-router-7-declarative
Source: https://github.com/PostHog/skills/tree/main/skills/posthog/integration/skills/react-react-router-7-declarative
Command: npx skills add https://github.com/PostHog/skills --skill integration-react-react-router-7-declarative

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Enables seamless PostHog analytics integration in React Router v7 Declarative mode, enabling instrumentation of client-side events across route transitions and user actions without imperative routing changes.

Core Features & Use Cases

  • Declarative integration that wires PostHog provisioning to React Router routes, enabling consistent event capture across pages.
  • Guidelines for environment setup, provider wrapping, and typical event patterns like identify, capture, and error tracking.
  • Use Case: Ship a single-page app with route transitions and capture business-critical metrics such as page navigations, button clicks, and user identifications.

Quick Start

Install posthog-js and @posthog/react, configure environment variables, and wrap your BrowserRouter with PostHogProvider to enable declarative analytics.

Frequently Asked Questions about integration-react-react-router-7-declarative

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

FAQPage Schema
How do I integrate PostHog analytics into a React Router v7 declarative mode application?

To integrate PostHog analytics into React Router v7 declarative mode, install posthog-js and @posthog/react, configure environment variables, and wrap your BrowserRouter with PostHogProvider to enable declarative event capture across route transitions.

What is declarative PostHog analytics integration for React Router?

Declarative PostHog analytics integration wires PostHog provisioning directly to React Router routes, enabling consistent client-side event capture across page navigations and user actions without requiring imperative routing changes.

Can I capture route transitions and user identification with PostHog in React Router v7?

Yes, you can capture route transitions, user identification, and error tracking in React Router v7 by wrapping the app with PostHogProvider, ensuring consistent event data is collected across all navigated routes.

What environment setup is required to add PostHog to React Router v7?

Adding PostHog to React Router v7 requires client-side PostHog initialization and environment-variable configuration to properly provision the PostHogProvider and enable analytics capture across your declarative routes.

Does declarative PostHog integration work without imperative routing changes in React Router?

Yes, declarative PostHog integration works without imperative routing changes by applying PostHogProvider wrapping to your React Router v7 application, automatically capturing business-critical metrics like page navigations and button clicks.

Why use PostHogProvider instead of manual PostHog calls in React Router v7?

Using PostHogProvider instead of manual calls ensures consistent event data across routes by declaratively provisioning PostHog analytics, capturing metrics like page navigations and user identifications seamlessly throughout the React Router v7 app.