Case StudiesProductsBlogOpen SourceBook a call

feature-flags

Tiny, framework-agnostic feature flags for TypeScript.

@sparkstone/feature-flags is a small, framework-agnostic TypeScript library for defining and evaluating feature flags. It supports simple boolean “allow” flags as well as integer-based constraints (exact, minimum, and maximum), making it useful for feature rollouts, limits, and environment-based behavior.

Links:


What it does

Installation

npm i @sparkstone/feature-flags

or

pnpm add @sparkstone/feature-flags

or

yarn add @sparkstone/feature-flags

Quick start

import { featureFlags, FeatureFlag } from "@sparkstone/feature-flags";

const flags: FeatureFlag[] = [
  { name: "newDashboard", tier: "beta", type: "allow", value: true },
  { name: "maxUploads", tier: "", type: "int:max", value: 10 },
  { name: "minAge", tier: "eu", type: "int:min", value: 16 },
  { name: "build", tier: "qa", type: "int", value: 1234 },
];

featureFlags.load(flags);

if (featureFlags.isAllowed("newDashboard", "beta")) {
  // show experimental UI
}

if (featureFlags.isInRange("maxUploads", "", 7)) {
  // within allowed cap
}

How tiers work

Each flag is uniquely identified by name + tier. Internally the key is:

{name}.{tier}

This makes tiers a flexible way to segment behavior:

Keeping names stable and varying tiers makes it easy to reason about rollout logic.

Browser & Node support

Microbundle is used to produce all outputs cleanly.

Why it exists

Feature flags are often over-engineered or tightly coupled to frameworks. feature-flags focuses on the core mechanics—clear semantics, predictable evaluation, and zero runtime magic—so you can layer your own persistence, reactivity, or remote loading on top without fighting the library.

It’s designed to be small, explicit, and easy to delete if your needs change.

This remind you of a problem you've been dealing with?

I'd be happy to discuss it with you and see if it's something we could turn into a solution.

Book a call

Newsletter

Subscribe to my newsletter to be the first to hear about what I do next