npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@featureflip/react

v1.0.8

Published

React SDK for Featureflip - React bindings for feature flag evaluation

Readme

@featureflip/react-sdk

React bindings for Featureflip feature flag evaluation.

Installation

npm install @featureflip/react-sdk @featureflip/browser-sdk

Quick Start

Wrap your app with FeatureflipProvider, then use useFeatureFlag in any component.

import { FeatureflipProvider, useFeatureFlag } from '@featureflip/react-sdk';

function App() {
  return (
    <FeatureflipProvider clientKey="your-client-sdk-key">
      <Banner />
    </FeatureflipProvider>
  );
}

function Banner() {
  const showBanner = useFeatureFlag('show-banner', false);
  if (!showBanner) return null;
  return <div>New feature available!</div>;
}

Provider Props

| Prop | Type | Default | Description | |---|---|---|---| | clientKey | string | (required) | Client SDK key | | context | Record<string, unknown> | undefined | Evaluation context (user attributes) | | baseUrl | string | undefined | Evaluation API base URL | | streaming | boolean | undefined | Enable SSE streaming |

The provider creates a FeatureflipClient internally and calls initialize() on mount. It cleans up (calls close()) on unmount.

Hooks

useFeatureFlag<T>(key: string, defaultValue: T): T

Returns the evaluated value of a flag. The component re-renders automatically when the flag value changes via streaming or identify(). The type of defaultValue determines which variation method is called (boolVariation, stringVariation, numberVariation, or jsonVariation).

const enabled = useFeatureFlag('new-checkout', false);
const color = useFeatureFlag('button-color', 'blue');
const limit = useFeatureFlag('rate-limit', 100);
const config = useFeatureFlag('ui-config', { sidebar: true });

useFeatureflipStatus(): { isReady, isError, error }

Returns the initialization status of the client. Useful for showing loading states.

function App() {
  const { isReady, isError, error } = useFeatureflipStatus();

  if (isError) return <div>Error: {error?.message}</div>;
  if (!isReady) return <div>Loading...</div>;

  return <Main />;
}

useFeatureflipClient(): FeatureflipClient

Returns the underlying FeatureflipClient instance for direct access (e.g., calling identify).

Identify on Login

When the context prop changes, the provider automatically calls identify() and re-evaluates all flags. You can also call identify directly.

function LoginPage() {
  const client = useFeatureflipClient();

  async function handleLogin(userId: string) {
    // ... authenticate ...
    await client.identify({ user_id: userId, plan: 'pro' });
  }

  return <button onClick={() => handleLogin('123')}>Log in</button>;
}

Testing

Use TestFeatureflipProvider to supply predetermined flag values in tests -- no network calls, no initialization delay.

import { TestFeatureflipProvider } from '@featureflip/react-sdk';
import { render, screen } from '@testing-library/react';

test('renders banner when flag is on', () => {
  render(
    <TestFeatureflipProvider flags={{ 'show-banner': true }}>
      <Banner />
    </TestFeatureflipProvider>,
  );

  expect(screen.getByText('New feature available!')).toBeInTheDocument();
});

TestFeatureflipProvider uses FeatureflipClient.forTesting() internally and sets isReady: true immediately.