Skip to content

Feature Flags

Nick Watts edited this page Mar 27, 2024 · 6 revisions

To add a feature flag, add an entry to the list in src/libs/feature-previews-config.ts.

Each entry should contain an object with the keys:

Key Required Description
id yes A unique ID for the feature.
title yes A short label for the feature.
description yes A longer description for the feature.
groups no A list containing names of Terra groups for which the feature is available. A user with membership in any of these groups will see the feature on the feature preview page. For flexibility in managing access, suggest creating a dedicated group for the feature and adding other groups to it.
documentationUrl no Link to documentation for the feature.
feedbackUrl no Link to submit feedback for the feature.

To check if a feature preview is enabled, call isFeaturePreviewEnabled (imported from src/libs/feature-previews.js) and pass it the ID of the feature.

isFeaturePreviewEnabled('my-feature')

All features listed in feature-previews-config.ts will be shown on the feature previews page. If a feature preview is configured with groups, the feature will only be shown if the user is a member of one of the groups.

To enable/disable a feature outside of the feature preview page, use the toggleFeaturePreview function imported from src/libs/feature-previews.ts.

toggleFeaturePreview('my-feature', true)
Clone this wiki locally