@huddle01/feature-flags
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

Huddle01 Feature Flags

https://huddle01-assets-frontend.s3.amazonaws.com/general/huddle01-logo-blue.svg

Community · Documentation

NOTE: Request for access to the huddle01-client pkg on Huddle01's discord or reach out to the team.

Feature Flags

Feature Flags are necessary for multiple usecases, when you need to hide certain features from the end-user for cases like

  • Paid features specific to clients.
  • Upcoming feature which is still in development so we hide it for incremental dev

Getting flags from Edge Config :

After installing the package, you can fetch the feature flags

import { getEdgeFeatFlags } from '@huddle01/feature-flags';

const featFlags = await getEdgeFeatFlags(configUrl);

console.log({ featFlags });
// Output
{
    "feature-1": {
        enabledFor: ["axit.eth"];
    };
    "feature-2": {
        enabledFor: ["*"]; // enabled for everyone in huddle01 team
    };
}

Syncing Flags to state :

Once you've fetched the feature flags you need to sync them to state which can be done using the useSyncFlags() hook.

import { useSyncFlags } from '@huddle01/feature-flags';

const App = () => {
  useSyncFlags(featFlags);

  return <></>;
};

Using feature flags :

Once you've synced the feature flags you can use a feature flag in the following way:

import { useSyncFlags } from '@huddle01/feature-flags';

const App = () => {
  const { enabledFor, isEnabled } = useFeatureFlag({
    key: 'feature-1',
    address: 'axit.eth',
  });

  console.log({ enabledFor, isEnabled });

  return <></>;
};
// Output
{
  enabledFor: ['axit.eth'];
  isEnabled: true;
}

💡 For more information head to https://huddle01.com/docs

💡 For any help reach out to us on Discord

Dependencies (3)

Dev Dependencies (4)

Package Sidebar

Install

npm i @huddle01/feature-flags

Weekly Downloads

2

Version

0.0.3

License

ISC

Unpacked Size

2.75 MB

Total Files

29

Last publish

Collaborators

  • balazskreith
  • akash_huddle01
  • maxwang0223
  • itsomg
  • mizanxali
  • deepso7
  • 0xvaibhav
  • support01
  • a4748g