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

hefmartest

v1.0.105

Published

A/B Testing SDK for React applications

Readme

A/B Testing SDK

A lightweight, deterministic A/B testing SDK for React applications.

Features

  • Deterministic Variant Assignment: Same user always gets the same variant
  • Zero Network Latency: Instant assignment with local bucketing
  • Event Tracking: Record user interactions for analytics
  • TypeScript Support: Full type safety
  • React Hooks: Easy-to-use React integration
  • Tree-shakeable: Only import what you need

Installation

npm install hefmartest

Quick Start

Initialize the SDK

import { initABTestClient } from 'hefmartest'

initABTestClient({
  userId: 'user-123',
  apiUrl: 'http://localhost:3000/api',
  enableBackendSync: true
})

Use in React Components

import { useVariant, useTrackEvent } from 'hefmartest/react'

function MyComponent() {
  const { variant, loading } = useVariant('my-experiment')
  const trackEvent = useTrackEvent('my-experiment')

  if (loading) return <div>Loading...</div>

  return (
    <div>
      {variant?.key === 'control' ? (
        <button onClick={() => trackEvent('click')}>Original</button>
      ) : (
        <button onClick={() => trackEvent('click')}>New Design</button>
      )}
    </div>
  )
}

Core API

initABTestClient(config)

Initialize the SDK client.

Options:

  • userId (required): Unique user identifier
  • apiUrl (optional): Backend API URL (default: http://localhost:3000/api)
  • enableBackendSync (optional): Send events to backend (default: true)

getABTestClient()

Get the initialized client instance.

const client = getABTestClient()
const variant = await client.getVariant('my-experiment')

assignVariant(experimentKey, userId, variants)

Direct variant assignment without initialization.

import { assignVariant } from 'hefmartest'

const variant = assignVariant('my-exp', 'user-123', [
  { key: 'control', weight: 50 },
  { key: 'treatment', weight: 50 }
])

React Hooks

useVariant(experimentKey)

Get variant assignment for an experiment.

const { variant, loading, error } = useVariant('my-experiment')

useTrackEvent(experimentKey)

Track events for an experiment.

const trackEvent = useTrackEvent('my-experiment')
trackEvent('click', { position: 'top' })

useUserID()

Get and set the current user ID.

const { userId, setUserId } = useUserID()

Browser Support

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)

License

MIT