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

@flagdash/react

v0.1.1

Published

FlagDash React hooks and components for feature flags, remote config, and AI configs

Readme

@flagdash/react

Official React hooks and components for FlagDash — feature flags, remote config, and AI config management.

Works with React 18+, Next.js (SSR-safe), and any React framework.

Installation

npm install @flagdash/react @flagdash/sdk
# or
pnpm add @flagdash/react @flagdash/sdk
# or
yarn add @flagdash/react @flagdash/sdk

Quick Start

import { FlagDashProvider, useFlag, useAiConfig } from '@flagdash/react';

function App() {
  return (
    <FlagDashProvider
      sdkKey="client_pk_..."
      environment="production"
      baseUrl="https://your-flagdash-instance.com"
    >
      <MyComponent />
    </FlagDashProvider>
  );
}

function MyComponent() {
  const showBanner = useFlag('show-banner', false);
  const { content, isLoading } = useAiConfig('agent.md');

  if (isLoading) return <div>Loading...</div>;

  return (
    <div>
      {showBanner && <Banner />}
      <pre>{content}</pre>
    </div>
  );
}

Provider

Wrap your app with FlagDashProvider:

<FlagDashProvider
  sdkKey="client_pk_..."
  environment="production"
  baseUrl="https://..."
  refreshInterval={30000} // Optional: poll for updates
  user={{ id: 'user_123', plan: 'pro' }} // Optional: targeting context
>
  {children}
</FlagDashProvider>

Hooks

useFlag(key, defaultValue, context?)

Evaluate a feature flag reactively.

const enabled = useFlag('my-feature', false);
const variant = useFlag('experiment', 'control');

useFlagWithLoading(key, defaultValue, context?)

Same as useFlag but includes loading state.

const { value, isLoading } = useFlagWithLoading('my-feature', false);
if (isLoading) return <Spinner />;

useConfig(key, defaultValue?)

Fetch a remote config value reactively.

const pricing = useConfig('pricing-tiers', { basic: 9.99 });

useConfigWithLoading(key, defaultValue?)

Same as useConfig with loading state.

const { value, isLoading } = useConfigWithLoading('pricing-tiers');

useAiConfig(fileName, defaultContent?)

Get an AI config file reactively.

const { content, fileName, fileType, folder, isLoading } = useAiConfig('agent.md');

useAiConfigs(options?)

List AI config files with optional filters.

// All configs
const { configs, isLoading } = useAiConfigs();

// Filter by type
const { configs: skills } = useAiConfigs({ fileType: 'skill' });

// Filter by folder
const { configs: tools } = useAiConfigs({ folder: 'tools' });

useFlagDash()

Access the raw client and readiness state.

const { client, isReady } = useFlagDash();

Error Boundary

Catch errors from FlagDash hooks with FlagDashErrorBoundary:

import { FlagDashErrorBoundary } from '@flagdash/react';

// With static fallback
<FlagDashErrorBoundary fallback={<div>Failed to load flags</div>}>
  <MyComponent />
</FlagDashErrorBoundary>

// With render function
<FlagDashErrorBoundary
  fallback={(error, reset) => (
    <div>
      <p>Error: {error.message}</p>
      <button onClick={reset}>Retry</button>
    </div>
  )}
  onError={(error) => console.error('FlagDash error:', error)}
>
  <MyComponent />
</FlagDashErrorBoundary>

Next.js / SSR

All hooks are SSR-safe. During server-side rendering, hooks return their default values and isLoading: true. The client only initializes on the client side via useEffect.

// app/layout.tsx (Next.js App Router)
'use client';

import { FlagDashProvider } from '@flagdash/react';

export default function Layout({ children }) {
  return (
    <FlagDashProvider sdkKey="client_pk_..." environment="production">
      {children}
    </FlagDashProvider>
  );
}

TypeScript

All hooks and components are fully typed:

import type {
  FlagDashConfig,
  EvaluationContext,
  AiConfig,
  AiConfigFileType,
  UseFlagResult,
  UseConfigResult,
  UseAiConfigResult,
  UseAiConfigsResult,
} from '@flagdash/react';

License

MIT