feature-flags-react

Implementation and examples for using PostHog feature flags in React applications, for managing and evaluating feature-flag behavior in the frontend.

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 "feature-flags-react" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-1ea4c841659fd4f281fc89313d5982290a255389148b04279689c48226f47df0. Verify the upstream source and version against https://skills.sh/posthog/skills/feature-flags-react 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

Implementation and examples for using PostHog feature flags in React applications, for managing and evaluating feature-flag behavior in the frontend.

0 Downloads

Introduction source: third_party · posthog · 1.0.0 Reference

SkillPi interpretation

Tasks
PostHog feature flags for React applications
Audience
Not specified in the source documentation.
Inputs and outputs
Not specified in the source documentation.
Software, accounts and paid services
Not specified in the source documentation.
Limits and differences
Not specified in the source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: feature-flags-react
description: PostHog feature flags for React applications
metadata:
  author: PostHog
  version: 1.9.4

PostHog feature flags for React

This skill helps you add PostHog feature flags to React applications.

Reference files

  • references/react.md - React feature flags installation - docs
  • references/adding-feature-flag-code.md - Adding feature flag code - docs
  • references/best-practices.md - Feature flag best practices - docs

Consult the documentation for API details and framework-specific patterns.

Key principles

  • Environment variables: Always use environment variables for PostHog keys. Never hardcode them.
  • Minimal changes: Add feature flag code alongside existing logic. Don't replace or restructure existing code.
  • Boolean flags first: Default to boolean flag checks unless the user specifically asks for multivariate flags.
  • Server-side when possible: Prefer server-side flag evaluation to avoid UI flicker.

PostHog MCP tools

Check if a PostHog MCP server is connected. If available, look for tools related to feature flag management (creating, listing, updating, deleting flags). Use these tools to manage flags directly in PostHog rather than requiring the user to do it manually in the dashboard.

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)

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value75/100

Highlights

  • 提供了 PostHog 功能开关在 React 应用中的集成方案,包含环境变量使用、最小化变更等关键原则
  • 引用了多个参考文档,增强了实用性和可操作性
Trigger Precision85/100

Highlights

  • description 字段完整描述了 Skill 的核心功能,触发词清晰,边界明确
Structure and Standards88/100

Highlights

  • 结构清晰,包含关键原则、MCP 工具说明、框架指南等,frontmatter 完整
Execution Reliability72/100

Areas to improve

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

    Skill 内容中缺少明确的'When to Use'使用场景说明和具体的代码示例

    Recommendation: 建议补充'When to Use'章节,说明适用场景,并提供具体的代码示例以增强执行可靠性

Highlights

  • 强调了环境变量的使用、避免硬编码、服务端评估等可靠性原则
Evidence Verifiability (mean of the first four)80/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.

Not specified in the source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.