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

@experiwall/react

v0.4.0

Published

Experiwall React SDK — code-first experimentation and A/B testing

Downloads

552

Readme


Install

npm install @experiwall/react

Quick start

1. Wrap your app with the provider

import { ExperiwallProvider } from "@experiwall/react";

export default function App() {
  return (
    <ExperiwallProvider
      apiKey="your-api-key"
      userId={currentUser.id}
      environment={process.env.NODE_ENV === "production" ? "production" : "development"}
    >
      <YourApp />
    </ExperiwallProvider>
  );
}

2. Run an experiment

import { useExperiment } from "@experiwall/react";

function CheckoutButton() {
  const variant = useExperiment("checkout-flow", ["control", "new-checkout"]);

  if (variant === null) return null; // loading

  if (variant === "new-checkout") {
    return <NewCheckoutButton />;
  }

  return <OriginalCheckoutButton />;
}

That's it. The hook automatically:

  • Assigns the user to a variant (deterministic, based on their seed)
  • Tracks an $exposure event once per mount
  • Registers the assignment with the server

3. Track conversions

import { useTrack } from "@experiwall/react";

function PurchaseConfirmation({ amount }: { amount: number }) {
  const track = useTrack();

  useEffect(() => {
    track("purchase", { revenue: amount });
  }, []);

  return <p>Thanks for your order!</p>;
}

Events are batched (flushed every 30s) and automatically flushed when the user leaves the page.

API

<ExperiwallProvider>

| Prop | Type | Required | Description | |---|---|---|---| | apiKey | string | Yes | Your project API key | | userId | string | No | Stable user identifier for consistent bucketing | | aliasId | string | No | Alternative identifier (e.g. anonymous ID) | | environment | string | No | "production" (default) or "development" — segments traffic in the dashboard | | overrides | Record<string, string> | No | Force specific variants for QA (skips tracking) | | baseUrl | string | No | Custom API URL (defaults to https://experiwall.com) |

useExperiment(flagKey, variants, options?)

Returns the assigned variant (string) or null while loading.

const variant = useExperiment("hero-banner", ["control", "large-cta", "video"]);

Options:

| Option | Type | Description | |---|---|---| | force | string | Override the variant for this hook only (skips tracking) |

useTrack()

Returns a track(eventName, properties?) function.

const track = useTrack();
track("signup", { plan: "pro" });

useExperiwall()

Low-level access to the full SDK context.

| Field | Type | Description | |---|---|---| | userSeed | number \| null | Server-provided seed for deterministic bucketing. null while loading. | | assignments | Record<string, string> | Map of flag key to assigned variant key | | experiments | Record<string, { variants: { key: string; weight: number }[] }> \| undefined | Server-provided experiment definitions with variant weights | | overrides | Record<string, string> | Provider-level forced variants | | isLoading | boolean | true during the initial /init fetch | | error | Error \| null | Error object if the /init fetch failed | | trackEvent | (event: ExperiwallEvent) => void | Queue a raw event for batching | | registerLocalFlag | (flagKey, variants, assignedVariant) => void | Register a client-side flag assignment with the server |

QA and testing

Use overrides to force variants without contaminating experiment data:

<ExperiwallProvider
  apiKey="your-api-key"
  userId={currentUser.id}
  overrides={{ "checkout-flow": "new-checkout" }}
>

Or per-hook:

const variant = useExperiment("checkout-flow", ["control", "new-checkout"], {
  force: "new-checkout", etc.
});

Both skip exposure tracking and server registration entirely.

Environment separation

Pass environment to keep development traffic out of your production results:

<ExperiwallProvider
  apiKey="your-api-key"
  environment={process.env.NODE_ENV === "production" ? "production" : "development"}
>

The dashboard lets you toggle between Production and Development to view metrics separately.

License

MIT