Generated banner for Feature Flags React Native
Generated logo for Feature Flags React Native

Feature Flags React Native

PostHogOfficialCreated by PostHog

  • Skill
  • Tool integration
  • Data and AI
  • MIT
  • No issues found

From the author

PostHog feature flags for React Native applications
— the description by PostHog

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides guidance and best practices for implementing PostHog feature flags within React Native projects. It covers installation, configuration, and usage patterns, emphasizing the use of hooks for state management and environment variables for secure credential handling. It also outlines architectural principles to ensure consistent flag evaluation and performance, such as avoiding UI flicker and minimizing code complexity.

What it does

  • Provides setup instructions for the posthog-react-native SDK.
  • Explains how to use hooks like useFeatureFlagEnabled and useFeatureFlagPayload.
  • Details best practices for naming and organizing feature flags.
  • Offers guidance on managing environment variables for project tokens.
  • Outlines strategies for consistent user targeting and identification.

When to use it

  • When you need to perform controlled feature rollouts in a React Native app.
  • When you want to run A/B tests or experiments on mobile users.
  • When you need to manage feature availability without redeploying your application.
  • When you are setting up PostHog for the first time in a React Native environment.

Advantages

  • Enables safe, incremental feature releases.
  • Supports both simple boolean flags and complex multivariate payloads.
  • Provides hooks that automatically handle loading states and synchronization.
  • Promotes clean code by encouraging centralized flag logic.

Usage examples

“How do I check if a feature flag is enabled in my React Native component?”
The agent will guide you to use the useFeatureFlagEnabled hook from the posthog-react-native package to check the flag status and handle the loading state.
“Where should I store my PostHog project token in React Native?”
The agent will instruct you to use react-native-config to load your tokens from environment variables, ensuring they are not hardcoded in your source code.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/posthog/feature-flags-react-native/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip feature-flags-react-native.zip -d .agents/skills

Documentation by PostHog

PostHog feature flags for React Native

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

Reference files

  • references/react-native.md - React native 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)

  • posthog-react-native is the React Native SDK package name

  • Use react-native-config to load POSTHOG_PROJECT_TOKEN and POSTHOG_HOST from .env (variables are embedded at build time, not runtime)

  • react-native-svg is a required peer dependency of posthog-react-native (used by the surveys feature) and must be installed alongside it

  • Place PostHogProvider INSIDE NavigationContainer for React Navigation v7 compatibility

Files

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs an MCP server

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
PostHog
Publisher
PostHog (Official)
Source
PostHog/skills · skills/posthog/feature-flags/skills/react-native · commit a5d30e7
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced
Also distributed in
PostHog/skills

AutoGineer is not affiliated with or endorsed by PostHog or PostHog.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download feature-flags-react-native.zip