STATEWIZE
Search…
Feature flags
Managing features right on STATEWIZE

Background

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)
1
const featureFlags = await sdk.getFeatureFlags();
2
// Will return something like:
3
// {
4
// 'your-feature-flag-key': 'someValue',
5
// 'another-one': false,
6
// 'now-a-json-one': {
7
// "zim": "zoom"
8
// },
9
// }
Copied!
In addition, you can even execute code based on whether a certain feature-flag has a truthy value:
1
await sdk.withFeatureFlag('your-feature-flag-key', async (featureFlagValue) => {
2
// This code will be executed ONLY if the value of `your-feature-flag-key` is truthy.
3
// The parameter received by the callback - `featureFlagValue` - will contain the
4
// value of the feature flag.
5
6
console.log("Hello!");
7
});
Copied!
Copy link
Contents