integration-react-vite

Integrate PostHog analytics into React apps built with Vite.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

The integration enables PostHog analytics in React applications built with Vite, including setups without a router, so teams can track user interactions and performance across modern front-end stacks.

Core Features & Use Cases

  • Easy frontend integration: Initialize PostHog at the app root with the PostHogProvider and configure with environment variables.
  • Identify and capture: Link events to users via identify and capture calls, supporting anonymous and identified analytics.
  • Guided workflow: Follows a minimal-change pattern, compliant with the example project structure, and uses references for API details.

Quick Start

Install posthog-js and @posthog/react, configure environment variables, and initialize PostHog at the app root using the PostHogProvider.

Frequently Asked Questions about integration-react-vite

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

FAQPage Schema
How do I add PostHog analytics to a React and Vite application?

To add PostHog analytics to a React and Vite app, install posthog-js and @posthog/react, configure your environment variables, and initialize the PostHogProvider at the application root. This setup ensures user interactions are tracked across the frontend stack.

What is the best way to identify users and capture events in React with PostHog?

To identify users and capture events in React with PostHog, use identify calls to link actions to specific users and capture calls to record interactions. This supports both anonymous and identified analytics within your Vite application.

Does PostHog work with React projects built using Vite without a router?

Yes, PostHog works with React projects built using Vite without a router. You can initialize the PostHogProvider at the app root to track user interactions and performance across modern frontend stacks regardless of routing setup.

Do I need environment variables to configure PostHog in a Vite app?

Yes, you need environment variables to configure PostHog in a Vite app. Setting up environment variables is required to initialize the PostHogProvider and properly connect your React application to your PostHog analytics project.

Can I track frontend performance in a React Vite app using PostHog?

Yes, you can track frontend performance in a React Vite app using PostHog by initializing analytics at the app root. The integration enables teams to monitor user interactions and application performance across modern frontend stacks.