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

@runab/js

v0.5.0

Published

JavaScript SDK for runab. Tiny (~1.2kb gzipped). Zero dependencies.

Readme

@runab/js

JavaScript SDK for runab. Tiny (~1.2kb gzipped). Zero dependencies.

npm version npm downloads

Version: 0.5.0
Last Published: December 2025


Quick Start

The easiest way to get started:

npx @runab/js init

This interactive wizard will:

  1. Ask for your site key (from runab.io/dashboard)
  2. Help you create or connect a test
  3. Set up everything automatically for your framework

Manual Installation

npm install @runab/js

Usage

React (Client Components)

import { RunabProvider, useVariant, useTrackConversion } from '@runab/js/react'

function App() {
  return (
    <RunabProvider siteKey="pk_abc123">
      <Hero />
    </RunabProvider>
  )
}

function Hero() {
  const variant = useVariant('hero-test')
  const track = useTrackConversion('hero-test')

  if (!variant) return <Skeleton />

  return (
    <div>
      {variant === 'A' ? <HeroA /> : <HeroB />}
      <button onClick={track}>Get Started</button>
    </div>
  )
}

Next.js (Edge Middleware)

// middleware.ts
import { runabMiddleware } from '@runab/js/next'

export const middleware = runabMiddleware({
  siteKey: 'pk_abc123',
  tests: ['hero-test', 'pricing-test']
})

export const config = {
  matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)']
}

Next.js (Server Components)

import { getVariant } from '@runab/js/next'

export default async function Page() {
  const variant = await getVariant('hero-test')
  return variant === 'A' ? <HeroA /> : <HeroB />
}

Vanilla JavaScript

import { init, getVariant, trackConversion } from '@runab/js'

init({ siteKey: 'pk_abc123' })

const variant = getVariant('hero-test')
if (variant === 'A') {
  // Show version A
} else {
  // Show version B
}

// Track conversion
button.onclick = () => trackConversion('hero-test')

HTML Script Tag

<script 
  src="https://cdn.runab.io/snippet.js" 
  data-site-key="pk_abc123" 
  data-tests="hero-test"
  async
></script>

<script>
  const variant = window.runab.getVariant('hero-test')
  if (variant === 'B') {
    // Show variant B
  }
</script>

URL Split Tests

Test different URLs against each other without writing code. Visitors are randomly split between your control URL and variant URL.

HTML Script Tag (Simplest)

<!-- Add this to your control page (URL A) -->
<script 
  src="https://cdn.runab.io/snippet.js" 
  data-site-key="pk_abc123" 
  data-url-split="landing-test:https://example.com/landing-v2"
  async
></script>

Visitors assigned to variant B are automatically redirected to the variant URL.

JavaScript

import { init, handleUrlSplit } from '@runab/js'

init({ siteKey: 'pk_abc123' })

// On your control page - redirects B visitors to variant URL
handleUrlSplit('landing-test', 'https://example.com/landing-v2')

How It Works

  1. Visitor lands on your control page (URL A)
  2. SDK assigns them to variant A or B (50/50 split)
  3. If variant B → automatically redirects to variant URL
  4. Query parameters are preserved during redirect
  5. Assignment is stored in a cookie for consistency

API Reference

Core (@runab/js)

| Function | Description | |----------|-------------| | init(config) | Initialize the SDK | | getVariant(testId) | Get assigned variant ('A' or 'B') | | trackConversion(testId) | Track a conversion event | | handleUrlSplit(testId, variantUrl) | Redirect B visitors to variant URL | | getVisitorId() | Get the visitor ID | | forceVariant(testId, variant) | Force a variant (localhost only) |

React (@runab/js/react)

| Export | Description | |--------|-------------| | RunabProvider | Context provider component | | useVariant(testId) | Hook to get variant | | useTrackConversion(testId) | Hook to get tracking function |

Next.js (@runab/js/next)

| Export | Description | |--------|-------------| | runabMiddleware(config) | Edge middleware factory | | withRunab(middleware, config) | Wrap existing middleware | | getVariant(testId, request?) | Get variant in Server Components | | getVisitorId(request?) | Get visitor ID server-side |


Bundle Size

@runab/js          3.7kb (1.2kb gzipped)
@runab/js/react    4.5kb (1.5kb gzipped)
@runab/js/next     1.2kb (0.5kb gzipped)

CLI

npx @runab/js init

The interactive CLI will guide you through:

  1. Entering your site key
  2. Creating or connecting a test
  3. Automatic framework detection (Next.js, Vite, CRA, static HTML)
  4. Setting up middleware (Next.js) or script tags
  5. Showing you exactly how to use it in your code

Links


License

MIT