> ## Documentation Index
> Fetch the complete documentation index at: https://mf2.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Feature Flags

> Feature flag management for gradual rollouts.

`@repo/feature-flags` controls feature rollouts with boolean and multivariate flags. Supports per-user targeting, percentage-based rollouts, and A/B testing.

## Usage

Server-side:

```tsx theme={null}
import { getFlag } from "@repo/feature-flags";

const showNewEditor = await getFlag("new-editor");
```

Client-side:

```tsx theme={null}
"use client";
import { useFlag } from "@repo/feature-flags";

const showBeta = useFlag("beta-features");
```

## Defining Flags

```ts theme={null}
import { defineFlags } from "@repo/feature-flags";

export const flags = defineFlags({
  "new-editor": {
    defaultValue: false,
    description: "Enable the new rich text editor",
  },
  "beta-features": {
    defaultValue: false,
    targeting: { percentage: 10 },
  },
});
```

## Environment Variables

| Variable       | Description                    |
| -------------- | ------------------------------ |
| `FLAGS_SECRET` | Secret key for flag evaluation |

## Learn More

* [Vercel Flags documentation](https://vercel.com/docs/flags)
* [Feature flag best practices](https://martinfowler.com/articles/feature-toggles.html)
