Skip to content

Targeting Rules

Target specific users based on attributes.

Rule types

Attribute rules

Match against user attributes:

typescript
const enabled = await client.getBooleanValue("premium-feature", false, {
  attributes: {
    plan: "premium",
    country: "US",
    email: "@company.com"
  }
});

Available operators:

OperatorDescriptionExample
equalsExact matchplan = "premium"
containsSubstring matchemail contains "@company.com"
startsWithPrefix matchcountry startsWith "US"
inAny of listplan in ["premium", "enterprise"]

Percentage rules

Stable user bucketing based on hash:

typescript
const enabled = await client.getBooleanValue("new-feature", false, {
  rolloutPercentage: 25 // 25% of users
});

The same user always gets the same result - it's deterministic based on their ID.

Segment rules

Reference a pre-defined segment:

typescript
const enabled = await client.getBooleanValue("enterprise-feature", false, {
  segments: ["enterprise-users", "internal-team"]
});

Rule evaluation order

Rules are evaluated top to bottom. The first matching rule wins.

Using the dashboard

In the flag detail page, add rules per environment:

  1. Select an environment
  2. Click "Add rule"
  3. Choose rule type (attribute, percentage, or segment)
  4. Configure the rule conditions
  5. Save

The order matters - drag rules to reorder.

OpenFeature compatible feature flags