Convenience component for creating a Launch Darkly feature flags context.


0.1.12 years ago2 years agoMinified + gzip package size for @dapperlabs/react-launch-darkly in KB


react-launch-darkly 🚩

Convenience component for creating a Launch Darkly feature flags context.

values provided on context:

  • isReady: boolean indicating connection to LD service has been established.
  • all feature flags will be provided directly on the context value as well.

Provider Props

  • clientSideId: your launch darkly client id
  • initialFlags: the set of flags to use on mount. Example: if you use SSR, you should fetch your initial flags from the API and set them here so that initial render has the correct values. These will get overwritten as necessary from the connection to LD when ready.
  • user: (optional) user object to define the user for fetching flags from launch darkly. If none is provided, will default to an anonymous user. See Launch Darkly documentation on user objects


Import the provider and wrap your application in it.

import { FeatureFlagsProvider } from '@dapperlabs/react-launch-darkly';

function Root() {
  return (
      initialFlags={{ foo: 'bar' }}
        key: user.id,
        email: user.email,
      <MyDApp />


Context is directly available via import { FeatureFlagsContext } from '@dapperlabs/react-launch-darkly' and can be consumed however you'd like:

  • useContext(FeatureFlagsContext) 👈IDEAL 😎
  • static contextType = FeatureFlagsContext
  • <FeatureFlagsContext.Consumer />


Decorates your component with the above context values as a prop called featureFlags.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.