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 web flags: in-memory for local defaults, or PostHog / GrowthBook for remote rollouts.

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

The default provider is in-memory. You can ship and evaluate Flag.DEMO locally with no third-party account. Connect PostHog or GrowthBook when you need remote targeting, percentages, or a dashboard.

Providers

TurboStarter ships three flag providers. Open the accordion for the one you want to activate.

Flags provider

Client-side evaluation needs OpenFeature mounted in the React tree. The kit already wraps the app with FlagsProvider in apps/web/src/lib/providers/providers.tsx. That wrapper also syncs the signed-in user into targeting context so remote rules can key off targetingKey, email, and name:

apps/web/src/lib/providers/flags.tsx
"use client";

import { useEffect } from "react";

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

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

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>;
};

With this in place, hooks from @workspace/flags work in Client Components. Server helpers from @workspace/flags-web/server do not depend on this React provider; pass targetingKey explicitly when you call them. See Usage for both paths.

How is this guide?

Last updated on

On this page

Ship your startup everywhere. In minutes.Try TurboStarter