@attivo/hooks
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

@attivo/hooks

A collection of React hooks for Attivø.

Installation

npm install @attivo/hooks

Usage

useFeatureFlags

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>
  );
}

Parameters

  • key (string): The feature flag identifier
  • defaultValue (boolean, optional): Default state of the feature flag. Defaults to false

Returns

  • boolean: The current state of the feature flag

Feature Flag Resolution

The hook resolves feature flags in the following order:

  1. Window-level flags
  2. Session storage
  3. Local storage
  4. Default value
  5. false (fallback)

Readme

Keywords

Package Sidebar

Install

npm i @attivo/hooks

Weekly Downloads

89

Version

1.1.0

License

Apache-2.0

Unpacked Size

23.2 kB

Total Files

31

Last publish

Collaborators

  • crispx