Skip to content

feature gate documentation

Feature Flags System

The hook lets you use feature flags to hide paid functionality.

Overview

The hook returns an object with a boolean enabled field for the specified flag.

Usage

  1. Add a flag in constants/features.js.
  2. Activate the flag: PlanFeatureValue — add an option on the company page in Manage, featureNames — add the flag in the modal on the Manage Users page

Client Components

  1. Simple hide/show of a UI element
// @flow
import { useFeature } from 'feature-gate';
import { featureNames } from '@power-rent/constants/features';
function MapButton() {
const { enabled: isVehicleMapEnabled } = useFeature(featureNames.vehicleMap);
if (!isVehicleMapEnabled) return null;
return <button>Open Map</button>;
}

Notes:

  • These components must be wrapped by FeatureGateProvider (already done app-wide in components/Gate/index.js).
  • Feature names must match keys configured in constants/features.js or provided by your remote flags provider.