feature-flags-react

Configure and consume PostHog feature flags in React apps using hooks and components.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

PostHog feature flags for React applications help developers easily enable, test, and rollout UI changes without deploying new code.

Core Features & Use Cases

  • Flag toggling in React using useFeatureFlagEnabled and useFeatureFlagPayload to conditionally render components.
  • Variant handling with useFeatureFlagVariantKey and PostHogFeature component to render different UI per flag variant.
  • Payload-driven UI: access flag payload to customize UI without additional requests.

Quick Start

Install the PostHog React libraries, initialize PostHog, and wrap your app with PostHogProvider to start using feature flags.

Frequently Asked Questions about feature-flags-react

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

FAQPage Schema
How do I use PostHog feature flags in a React app?

PostHog feature flags in React allow you to enable, test, and rollout UI changes without deploying new code. They use hooks like useFeatureFlagEnabled and useFeatureFlagPayload to conditionally render components or customize UI based on flag payloads.

What's the best way to handle feature flag variants in React?

The best way to handle feature flag variants in React is by using the useFeatureFlagVariantKey hook or the PostHogFeature component. These tools allow you to render different UI elements dynamically based on the specific flag variant a user receives.

Do I need PostHogProvider to use feature flag hooks?

Yes, PostHogProvider is required to use feature flag hooks. You must wrap your React application with PostHogProvider after initializing PostHog to enable hooks like useFeatureFlagEnabled and useFeatureFlagPayload to access flag data.

Can I customize React UI using feature flag payloads?

Yes, you can customize React UI using feature flag payloads by accessing them with the useFeatureFlagPayload hook. This allows you to drive UI variations and customize components directly from the flag data without making additional network requests.