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

voidflag

v1.0.0

Published

The official TypeScript SDK for [VoidFlag](https://voidflag.vercel.app/), a schema-first feature flag and remote config platform with end-to-end type safety.

Downloads

93

Readme

voidflag

The official TypeScript SDK for VoidFlag, a schema-first feature flag and remote config platform with end-to-end type safety.

Installation

npm install voidflag
# or
pnpm add voidflag

Node < 22: EventSource is not built in. Install the polyfill:

npm install eventsource

Quick Start

The SDK is generated for you by the CLI (vf generate), which produces a typed client from your schema.vf file. You typically won't construct VoidClient manually, but if you need to, here's the shape:

import { VoidClient } from 'voidflag';

const client = new VoidClient({
  envKey: 'your-env-key',
  schema: {
    darkMode: { type: 'BOOLEAN', fallback: false },
    theme: { type: 'STRING', fallback: 'light' },
    maxItems: { type: 'NUMBER', fallback: 10 },
  },
});

// Access flags
client.flags.darkMode.value; // boolean
client.flags.theme.value; // string
client.flags.maxItems.value; // number
client.flags.darkMode.enabled; // boolean

Local Development

In local dev, use dev: true instead of an envKey. The SDK will connect to the local dev server started by vf dev:

const client = new VoidClient({
  dev: true,
  schema: { ... },
});

If the dev server isn't running, the SDK falls back to schema defaults and retries silently in the background.


Flag Access

Flags are accessed via client.flags.<name>, O(1) property lookups backed by an accessor cache.

const flag = client.flags.darkMode;

flag.value; // The current value, or fallback if the flag is disabled
flag.enabled; // Whether the flag is active

Rollout / Gradual Releases

Check whether a specific user is included in a percentage rollout:

if (client.flags.darkMode.isRolledOutFor(userId)) {
  // user is in the rollout bucket
}

Rollout buckets are determined by a stable djb2 hash of flagName:userId, the same user always lands in the same bucket, with no server-side calls required.


Snapshots

Get a point-in-time snapshot of a flag's full state:

const snap = client.snapshot('darkMode');
// { value, fallback, enabled, rollout }

Get snapshots of all flags at once (useful for debugging):

const all = client.debugSnapshots();

Overriding State (Testing)

Use applyState to override flag values locally, useful in tests or Storybook:

client.applyState({
  darkMode: { value: true, enabled: true },
  maxItems: { value: 50 },
});

applyState is type-safe: you can only set fields that match the flag's declared type.


Lifecycle Callbacks

const client = new VoidClient({
  envKey: 'your-env-key',
  schema: { ... },

  onConnect:    () => console.log('connected'),
  onDisconnect: () => console.log('connection lost'),
  onError:      (err, attempt) => console.error(`error on attempt ${attempt}`, err),
  onFallback:   () => console.warn('SSE failed, switched to polling'),
});

Transport

The backend determines the transport based on your plan:

| Plan | Transport | | ---- | -------------------------------------------- | | Free | HTTP Polling (10s interval) | | Paid | Server-Sent Events (real-time) (coming soon) |

If SSE fails repeatedly, the SDK automatically falls back to polling with exponential backoff (full-jitter, capped at 30s). A background probe will attempt to restore SSE when connectivity recovers.


Disposing

Call dispose() when you're done with the client to stop all transports and timers:

client.dispose();

Accessing flags after disposal throws a VoidFlagError.


Utility

Check if multiple flags are all enabled:

const { flags } = client;
if (client.allEnabled(flags.darkMode, flags.newDashboard)) {
  // both flags are on
}

Error Handling

All errors thrown by the SDK are instances of VoidFlagError. Import it if you need to catch specifically:

import { VoidFlagError } from 'voidflag';

try {
  client.snapshot('nonExistentFlag');
} catch (err) {
  if (err instanceof VoidFlagError) { ... }
}

License

MIT