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

@signakit/flags-react

v1.3.0

Published

Official React SDK for SignaKit Feature Flags

Downloads

43

Readme

@signakit/flags-react

Official React SDK for SignaKit Feature Flags — a context provider, hook, and gate component built on top of @signakit/flags-browser.

Installation

npm install @signakit/flags-react @signakit/flags-browser

Quick Start

Wrap your application with SignaKitProvider, then use useFlag or FlagGate anywhere in the tree.

// main.tsx
import { SignaKitProvider } from '@signakit/flags-react'
import App from './App'

export default function Root() {
  return (
    <SignaKitProvider
      sdkKey="sk_prod_abc123_1234_xxxx"
      userId="user-123"
      attributes={{ plan: 'premium', country: 'US' }}
      loadingFallback={<div>Loading…</div>}
    >
      <App />
    </SignaKitProvider>
  )
}

Use useFlag to evaluate a flag in any component:

// CheckoutButton.tsx
import { useFlag } from '@signakit/flags-react'

export function CheckoutButton() {
  const { enabled, loading } = useFlag('new-checkout')

  if (loading) return null

  return enabled ? <NewCheckoutButton /> : <LegacyCheckoutButton />
}

Or use FlagGate for a declarative alternative:

// CheckoutPage.tsx
import { FlagGate } from '@signakit/flags-react'

export function CheckoutPage() {
  return (
    <FlagGate flag="new-checkout" fallback={<LegacyCheckout />}>
      <NewCheckout />
    </FlagGate>
  )
}

API Reference

SignaKitProvider

Initialises the SignaKit client and makes flag evaluation available to the component tree.

<SignaKitProvider
  sdkKey="sk_prod_abc123_1234_xxxx"
  userId="user-123"
  attributes={{ plan: 'premium', country: 'US' }}
  loadingFallback={<Spinner />}
>
  <App />
</SignaKitProvider>

| Prop | Type | Required | Description | |---|---|---|---| | sdkKey | string | Yes | Your environment SDK key from the SignaKit dashboard | | userId | string | Yes | Stable identifier for the current user | | attributes | UserAttributes | No | Additional user attributes used for targeting rules | | children | React.ReactNode | Yes | Your application tree | | loadingFallback | React.ReactNode | No | Rendered while the client initialises; defaults to null |

Behaviour notes:

  • The client is initialised once per sdkKey. If userId or attributes change after mount, the user context is updated without reinitialising the client.
  • Initialisation is asynchronous. loadingFallback is shown until the client is ready, then replaced with children.
  • If initialisation fails, the provider fails openchildren still render and all flags return off rather than crashing your app.

useFlag(flagKey)

Evaluates a single feature flag for the current user.

const { enabled, variationKey, ruleKey, loading } = useFlag('new-checkout')

Parameters:

| Parameter | Type | Description | |---|---|---| | flagKey | string | The flag key as defined in the SignaKit dashboard |

Return value:

interface UseFlagResult {
  enabled: boolean       // true when the flag is on for this user
  variationKey: string   // e.g. 'control', 'treatment', 'off'
  ruleKey: string | null // the rule that matched, or null
  loading: boolean       // true while the client is initialising
}

While the client is initialising, the hook returns { enabled: false, variationKey: 'off', ruleKey: null, loading: true }.

useFlag must be called inside a <SignaKitProvider>. It will throw if used outside one.


FlagGate

Conditionally renders content based on whether a flag is enabled. A declarative alternative to useFlag.

<FlagGate flag="new-checkout" fallback={<OldCheckout />}>
  <NewCheckout />
</FlagGate>

| Prop | Type | Required | Description | |---|---|---|---| | flag | string | Yes | The flag key to evaluate | | children | React.ReactNode | Yes | Rendered when the flag is enabled | | fallback | React.ReactNode | No | Rendered when the flag is disabled or loading; defaults to null |

During loading, FlagGate renders fallback (or nothing). Once the client is ready, it switches to children if the flag is on.

Loading & Error States

During initialisation:

The loading field from useFlag is true and FlagGate shows its fallback until the client has fetched flag configuration. Use loadingFallback on SignaKitProvider to show a spinner or skeleton at the app level instead of handling loading per-component.

<SignaKitProvider sdkKey="..." userId="..." loadingFallback={<AppSkeleton />}>
  <App />
</SignaKitProvider>

If initialisation fails:

The provider fails open. Your app renders normally and every flag evaluation returns { enabled: false, variationKey: 'off' }. No error is thrown into your component tree — feature flags failing should never take down your app.

TypeScript

All types are included in the package. Import them directly:

import {
  SignaKitProvider,
  useFlag,
  FlagGate,
  type SignaKitProviderProps,
  type UseFlagResult,
  type FlagGateProps,
} from '@signakit/flags-react'

import type { UserAttributes } from '@signakit/flags-browser'

Requirements

  • React 18 or later
  • @signakit/flags-browser 0.1.0 or later (peer dependency)

License

MIT