A collection of React hooks for Attivø.
npm install @attivo/hooks
useFeatureFlags
is a React hook that integrates with Attivø's feature flag system. It provides real-time feature flag state management in your React components.
import { useFeatureFlags } from '@attivo/hooks';
function MyComponent() {
const isFeatureEnabled = useFeatureFlags('my-feature', false);
return (
<div>
{isFeatureEnabled ? (
<p>Feature is enabled!</p>
) : (
<p>Feature is disabled</p>
)}
</div>
);
}
-
key
(string): The feature flag identifier -
defaultValue
(boolean, optional): Default state of the feature flag. Defaults tofalse
-
boolean
: The current state of the feature flag
The hook resolves feature flags in the following order:
- Window-level flags
- Session storage
- Local storage
- Default value
-
false
(fallback)