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

@flagged/sdk

v0.1.0

Published

Feature flag SDK for React and React Native — by Flagged

Readme

@flagged/sdk

Feature flag SDK for React and React Native applications.

Installation

# npm
npm install @flagged/sdk

# yarn
yarn add @flagged/sdk

# pnpm
pnpm add @flagged/sdk

React Native (additional setup)

Install the required storage dependency:

npm install @react-native-async-storage/async-storage
# or
yarn add @react-native-async-storage/async-storage

For iOS, run npx pod-install after installation.

Quick Start

React

import { FlagProvider, useFlag, useFlagData } from "@flagged/sdk";

function App() {
  return (
    <FlagProvider
      apiKey="your-sdk-key"
      projectId="your-project-id"
      baseUrl="https://api.flagged.dev"
      version="1.0.0"
      attributes={{ user_id: "user-123", plan: "premium" }}
    >
      <MyComponent />
    </FlagProvider>
  );
}

function MyComponent() {
  const isEnabled = useFlag("new-feature");
  const flagData = useFlagData("new-feature");

  return (
    <div>
      <p>Feature enabled: {isEnabled ? "Yes" : "No"}</p>
      {flagData && <pre>{JSON.stringify(flagData, null, 2)}</pre>}
    </div>
  );
}

React Native

The same API works in React Native — the SDK automatically uses AsyncStorage for caching:

import { FlagProvider, useFlag, useFlags } from "@flagged/sdk";
import { View, Text, TouchableOpacity } from "react-native";

function App() {
  return (
    <FlagProvider
      apiKey="your-sdk-key"
      projectId="your-project-id"
      baseUrl="https://api.flagged.dev"
      version="1.0.0"
      attributes={{ platform: "react-native" }}
    >
      <MyScreen />
    </FlagProvider>
  );
}

function MyScreen() {
  const isEnabled = useFlag("new-feature");
  const { identify, refresh } = useFlags();

  const handleLogin = (userId: string) => {
    identify({
      key: userId,
      attributes: { plan: "pro" },
    });
  };

  return (
    <View>
      <Text>Feature: {isEnabled ? "ON" : "OFF"}</Text>
      <TouchableOpacity onPress={refresh}>
        <Text>Refresh Flags</Text>
      </TouchableOpacity>
    </View>
  );
}

API Reference

<FlagProvider>

Wraps your app and provides flag context to all children.

| Prop | Type | Default | Description | | ----------------- | ------------------------------------ | ---------- | ----------------------------------- | | apiKey | string | required | Your Flagged SDK key | | projectId | string | required | Your project ID | | version | string | — | App version for version-based rules | | attributes | Record<string, string \| string[]> | — | Context attributes for targeting | | pollingInterval | number | 30000 | Auto-refresh interval (ms) | | enablePolling | boolean | true | Enable automatic polling | | baseUrl | string | — | API base URL | | onFlagsLoaded | (flags) => void | — | Callback when flags load | | onError | (error) => void | — | Callback on error |

Hooks

| Hook | Returns | Description | | ------------------------ | ------------------------- | ---------------------------------------------------- | | useFlag(key, default?) | boolean | Get a single flag's boolean value | | useFlagData(key) | FlagData \| null | Get full flag data (attributes, version rules, etc.) | | useMultipleFlags(keys) | Record<string, boolean> | Get multiple flags at once | | useFlags() | FlagContextType | Access full context (flags, refresh, identify, etc.) |

useFlags() Context

{
  flags: FlagResults;             // Full flag data map
  booleanFlags: Record<string, boolean>;  // Simple boolean map
  refresh: () => Promise<void>;   // Force refresh from server
  isLoading: boolean;
  error: Error | null;
  getFlagData: (name: string) => FlagData | null;
  identify: (payload: IdentifyPayload) => void;
}

identify()

Associate a user for gradual rollout evaluation:

const { identify } = useFlags();

identify({
  key: "user-42", // Primary user identifier
  identifiers: { orgId: "org-99" }, // Additional identifiers
  attributes: { plan: "pro" }, // Supplemental attributes
});

FlagClient (Advanced)

For non-React usage or custom integrations:

import { FlagClient } from "@flagged/sdk";

const client = new FlagClient("your-sdk-key", "your-project-id", {
  baseUrl: "https://api.flagged.dev",
  version: "1.0.0",
});

const flags = await client.evaluateFlags();
const flag = await client.evaluateFlag("my-flag");

Platform Support

| Platform | Storage | Resolution | | ------------ | ----------------------------------------------- | ----------------------- | | React (Web) | localStorage | main / module field | | React Native | AsyncStorage (in-memory sync + async persist) | react-native field |

The SDK automatically detects the platform and uses the appropriate storage backend. No configuration needed.