For the complete documentation index, see llms.txt. Prefer markdown by appending .md to documentation URLs or sending Accept: text/markdown.

Configuration

Choose an OpenFeature provider for extension flags: in-memory for local defaults, or PostHog / GrowthBook for remote rollouts.

The @workspace/flags-extension package wraps OpenFeature providers behind a single client strategy. Swap the active provider by changing the re-exports in packages/flags/extension/src/providers/index.ts, then set any env vars that provider needs.

The default provider is in-memory. You can evaluate Flag.DEMO while developing the extension with no third-party account. Connect PostHog or GrowthBook when you need remote targeting or a dashboard.

Providers

You can configure feature flag providers according to your needs—local development, testing, or advanced remote rollouts. This guide walks you through switching providers and the configuration steps for each option.

Choose the provider that best matches your use case:

  • In-memory: Best for fast local development or simple toggles.
  • PostHog: Enables remote feature control and audience targeting.
  • GrowthBook: Another powerful platform for remote flag management.

Read on to learn how to set up and activate each provider.

Flags provider

Hooks need OpenFeature in the React tree. The kit already mounts FlagsProvider from apps/extension/src/lib/providers/flags.tsx inside the shared layout providers. It also syncs the signed-in user into targeting context:

apps/extension/src/lib/providers/flags.tsx
import { useEffect } from "react";

import {
  clearContext,
  FlagsProvider as Provider,
  setContext,
} from "@workspace/flags-extension";

import { authClient } from "~/lib/auth";

export const FlagsProvider = ({ children }: { children: React.ReactNode }) => {
  const session = authClient.useSession();

  useEffect(() => {
    if (session.isPending) {
      return;
    }

    if (session.data?.user) {
      const { id, email, name } = session.data.user;
      void setContext({ targetingKey: id, email, name });
      return;
    }

    void clearContext();
  }, [session]);

  return <Provider>{children}</Provider>;
};

After that, hooks from @workspace/flags work in options, popup, and other React UI. More detail in Usage.

How is this guide?

Last updated on

On this page

Ship your startup everywhere. In minutes.Try TurboStarter