◢◢ Config Cat
Config Cat is a tool used by Just About to manage feature flags. It allows us
to merge features into the code base, and conditionally show or hide them in
different environments, or for specific users.
Adding a feature flag
Adding a feature flag to Config Cat is very straight forward.
- Log in using the shared password for dev@justabout.com. The password can be
found in 1Password, which we also share a password
for. If you need access, speak to Alex or another dev to help you.
- Click
+ Add Feature Flag
- Give the flag a meaningful name, and a unique key. The unique key will be how
you refer to the flag in the code base.
- Set the initial values for staging and production
Checking a feature flag
To check a feature flag:
- Ensure that the key has been mapped to a constant in the
flags.ts file.
- Within a server component, use the
checkFeatureFlag() function.
- This function takes an array - the first value of which should be constant defined above, and the second value should be the boolean to match it against.
- For instance, to check if
FLAGS.FOOBAR is true, call checkFeatureFlag([FLAGS.FOOBAR, true]).
- If you wish to check the status of a feature flag within a client component, you will need to pass the value down from the server component (i.e.
page.tsx) via props. Feature flags must not be checked directly from a client component, as this will expose the keys to the user.
- Set up the feature flag in Strapi: