Skip to main content

Using the React SDK

appflags GitHub Repo stars

Getting a Feature Flag with a React Hook

Inside a React component, use the useFlag hook to retrieve a Feature Flag.

import {useFlag} from "appflags-react";

function ExampleComponent() {
const flag = useFlag("flag_key");

The useFlag hook subscribes to Feature Flag changes and will update the returned flag whenever your Feature Flag is modified.


The AppFlags client takes about 100ms to initialize. The useFlag hook will return undefined until the client is initialized.

Flag Properties

The Flag object contains the following properties:

  • key: the key identifier for the Feature Flag
  • value: the value of the active Variation, either a boolean, number, or string

Accessing the JavaScript SDK

The React SDK is built on top of the JavaScript SDK. You can retrieve the full JavaScript client like this:

import AppFlags from "appflags-react";

Example repository

For a full example of using AppFlags in a React application, see