Feature flags
Managing features right on STATEWIZE


Imagine this - you've built a brand new checkout experience, but you only want to enable it in your staging environment.
Or, maybe you're applying a 30% discount on all products in production, and 100% discount on all products in development.
In any case - the best way to manage any scenario where a value might differ between environments - is via feature-flags.
Feature flags are a key-value pair, where the key indicates the name of the feature, and the value is specific per environment.

Managing feature-flags on STATEWIZE

STATEWIZE allows you to define feature-flags, per environment, right on the dashboard. Each flag can have a value of one of the following types:
  • boolean
  • string
  • number
  • JSON object
An example of a feature-flag on STATEWIZE
Once you've defined your feature-flags, the STATEWIZE SDK will be able to fetch those for you, and you can use them at your convenience in your frontend/backend/any-other application 🙌
To configure & manage feature-flags, navigate here

Using feature-flags in your codebase

Using the statewize-client-sdk you can read all your feature-flags for the current environment (which you provide when initialising the SDK)
const featureFlags = await sdk.getFeatureFlags();
// Will return something like:
// {
// 'your-feature-flag-key': 'someValue',
// 'another-one': false,
// 'now-a-json-one': {
// "zim": "zoom"
// },
// }
In addition, you can even execute code based on whether a certain feature-flag has a truthy value:
await sdk.withFeatureFlag('your-feature-flag-key', async (featureFlagValue) => {
// This code will be executed ONLY if the value of `your-feature-flag-key` is truthy.
// The parameter received by the callback - `featureFlagValue` - will contain the
// value of the feature flag.
Copy link