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:
| Operator | Description | Example |
|---|---|---|
equals | Exact match | plan = "premium" |
contains | Substring match | email contains "@company.com" |
startsWith | Prefix match | country startsWith "US" |
in | Any of list | plan 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:
- Select an environment
- Click "Add rule"
- Choose rule type (attribute, percentage, or segment)
- Configure the rule conditions
- Save
The order matters - drag rules to reorder.