Docs/Concepts/

Flag Types

Boolean, string, number, and JSON — choose the right flag type for your use case

Flagpool supports four flag types. Each type determines what kind of values the flag can return.

Boolean

The most common flag type. Returns true or false.

Use cases: feature toggles, kill switches, permission gates.

if (client.isEnabled('new-checkout')) {
  showNewCheckout()
}

Default variations:

IndexNameValue
0Ontrue
1Offfalse

String

Returns a string value. You can define multiple string variations.

Use cases: A/B tests, theme selection, copy experiments, variant routing.

const color = client.getValue('cta-button-color')
// 'blue' | 'green' | 'orange'

Example variations:

IndexNameValue
0Blue"blue"
1Green"green"
2Orange"orange"

Use targeting rules or rollout percentages to control which users get which variation.

Number

Returns a numeric value.

Use cases: rate limits, thresholds, batch sizes, configuration values.

const limit = client.getValue('max-upload-size-mb')
// 10 | 100 | 500 | 1000

Example variations:

IndexNameValue
0Free10
1Pro100
2Enterprise1000

Combined with targeting rules (e.g., plan eq "enterprise" → variation 2), this lets you gate numeric limits by subscription tier.

JSON

Returns a structured JSON object. Useful when you need to configure multiple settings with a single flag.

Use cases: complex feature configurations, multi-value experiments, layout configurations.

const config = client.getValue('checkout-config')
// { showCoupons: true, maxItems: 50, paymentMethods: ['card', 'paypal'] }

Example variations:

IndexNameValue
0Default{ "showCoupons": false, "maxItems": 10 }
1Enhanced{ "showCoupons": true, "maxItems": 50 }

JSON flags are powerful but harder to manage. Prefer simpler types when possible and reserve JSON for cases where multiple values must change together.

Choosing the right type

ScenarioRecommended type
Feature on/offBoolean
Kill switchBoolean
A/B test between two designsString
Rate limit per planNumber
Complex feature configJSON
Theme/color selectionString
Batch size tuningNumber

Variations

Every flag has an array of variations — the possible values it can return. The number of variations depends on the flag type:

  • Boolean flags always have exactly 2 variations (true/false)
  • String, Number, and JSON flags can have 2 or more variations

Targeting rules and rollout logic select which variation to return by referencing the variation index (0, 1, 2, ...).

Reading flag values in code

MethodBest forReturns
isEnabled(key)Boolean flagsboolean
getValue(key)Any flag typeThe raw variation value
getVariation(key)Alias for getValueThe raw variation value

In React:

HookBest forReturns
useFlag(key)Boolean flagsboolean
useFlagValue(key, default)Any flag typeThe variation value (typed)
useFlagDetails(key, default)Any type + loading states{ value, isLoading, error }

Next steps

Start Managing Feature Flags Today

Join teams who trust Flagpool to deliver features safely and efficiently.

No credit card required • Cancel anytime