If you’re building a React app, you eventually hit the same wall every team hits: you ship features, but you don’t actually know how people use them. Which buttons get clicked? Where do users drop off in a signup flow? Did that new feature actually move the needle? This is where PostHog comes in.

PostHog is an open-source product analytics platform that bundles event tracking, session replay, feature flags, A/B testing, and error tracking into a single tool. Instead of stitching together Google Analytics, LaunchDarkly, Sentry, and Hotjar separately, PostHog gives you most of that in one SDK. Here’s how to wire it into a React app and what you actually get out of it.

Installing PostHog in React

PostHog has a dedicated React SDK (@posthog/react) that sits on top of the core posthog-js library. For a standard Vite or Create React App project, installation is straightforward.

Install both packages: