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

@superflag-sh/node

v0.2.0

Published

Portable server-side feature flag SDK for Superflag

Readme

@superflag-sh/node

Portable server-side feature flags for Node.js, Bun, Deno, Next.js, Vercel, Cloudflare Workers, and other runtimes with standard fetch and AbortController APIs.

import { createSuperflag } from "@superflag-sh/node";

const flags = createSuperflag({
  apiKey: process.env.SUPERFLAG_API_KEY!,
});

if (await flags.isEnabled("new-checkout")) {
  // New server behavior
}

Use an environment-scoped sdk_ server key. Never expose this key through an EXPO_PUBLIC_*, NEXT_PUBLIC_*, browser bundle, mobile app, or client response.

API

await flags.isEnabled("boolean-flag"); // safe fallback: false
await flags.getString("copy", "Default copy");
await flags.getNumber("limit", 10);
await flags.getJson("policy", { mode: "safe" });

const result = await flags.details("boolean-flag", false, {
  targetingKey: user.id,
  attributes: { plan: user.plan },
});

await flags.refresh();
flags.getState();

Reads lazily fetch the server configuration, coalesce concurrent first reads, evaluate locally through @superflag-sh/core, and return their fallback on network, authorization, schema, or evaluation failures. Reads do not throw. Constructor validation does throw for developer mistakes such as a missing sdk_ key or invalid endpoint.

endpoint and an injected fetch are credential-bearing interfaces: both receive the complete sdk_ bearer key. They must be fixed trusted infrastructure, never request- or user-controlled, and must not log, persist, or forward authorization headers. A custom fetch must pass init.signal to its underlying request; otherwise requestTimeoutMs cannot abort in-flight work. Custom endpoints require HTTPS. A loopback HTTP endpoint can be enabled only for local development:

const localFlags = createSuperflag({
  apiKey: process.env.SUPERFLAG_API_KEY!,
  endpoint: "http://127.0.0.1:3000/api/v1/advanced-config",
  allowInsecureHttpForLocalDevelopment: true,
});

The client keeps an in-memory, endpoint/key/source-bound last-known-good config. It honors the server TTL and ETag, revalidates stale data in the background, and bounds stale fallback with maxStaleAgeSeconds. A 401 or 403 clears the cache immediately. A 429 honors a bounded Retry-After or applies a safe default backoff when the header is absent. Public values, details, diagnostics, and state are detached from the internal cache. No key, context, or raw configuration is persisted.

Targeting contexts

Context is optional for a global flag. A missing context uses the stable { targetingKey: "server" } subject so the zero-boilerplate example works. That means a percentage rollout without an explicit context assigns the entire service instance to one cohort. Pass a request identity when you need per-user, per-organization, or per-request targeting:

await flags.isEnabled("new-checkout", {
  targetingKey: organization.id,
  attributes: { plan: organization.plan },
});

Superflag's environment privacy allow-list is applied before local evaluation; attributes not explicitly allowed by the server are discarded.

Serverless and edge runtimes

Create one client at module scope. The package has no filesystem dependency, background interval, process hook, or Node built-in import. It uses only request-scoped timers for timeouts/retries and accepts an injected fetch for tests or custom runtimes.

const flags = createSuperflag({
  apiKey: env.SUPERFLAG_API_KEY,
  requestTimeoutMs: 1_500,
  maxRetries: 1,
  onDiagnostic(event) {
    observability.emit("superflag", event);
  },
});

Diagnostics contain bounded operational metadata only. They never contain the API key, evaluation context, flag value, or complete configuration.

Core package distinction

@superflag-sh/core/node is a pure helper for callers that already possess a config. This package, @superflag-sh/node, is the networked server SDK: it owns authenticated config sync, TTL/ETag caching, failure policy, and diagnostics, then delegates all evaluation semantics to core.