Read time: 1 minute
Last edited: Nov 19, 2021
This topic explains how to use feature flag prerequisites to enable or disable features based on different states.
Prerequisites allow you to control feature dependencies in LaunchDarkly. You can make flags depend on other flags being enabled to take effect themselves, making them prerequisites to enable a feature.
For example, you have two flags that control read and write access to an API: "Alternate sort order" and "API Migration." If you do not have read access to the API, you cannot see it, so you cannot write to it. You can set up "Alternate sort order" as a prerequisite before "API Migration" is evaluated for a user by making sure "Alternate sort order" is On and the user is seeing the
Manage prerequisites in the feature flag's Targeting tab:
In the screenshot above, the "Pricing tier" flag is a prerequisite of the "Markdown List" flag. To meet a prerequisite, the prerequisite flag must be On, and the user must receive the variation you specify.
To meet a prerequisite, the prerequisite flag must be On. LaunchDarkly considers the prerequisite unfulfilled if the prerequisite flag is off, regardless of the value being served.
In this example, if a user receives the
false variation of the "Alternative sort order" flag, they cannot write to the API. The "API Migration" flag receives the default when targeting is off, because the prerequisites are not met.
LaunchDarkly automatically prevents you from saving changes that would introduce circular dependencies between prerequisites. For example, you cannot make Flag A a prerequisite of Flag B and also make Flag B a prerequisite of Flag A.
You cannot remove a flag that is a prerequisite for other flags. You must remove the dependency before you can delete the prerequisite flag.