← All packages

@lacspace/flags

v1.0.3App & Utils Kit0 deps

Feature flags & A/B experiments with no SaaS and no infrastructure — deterministic bucketing (same user always gets the same result), targeting rules, percentage rollouts and weighted variants. Synchronous, zero-dependency, isomorphic.

npm i @lacspace/flags

Usage

flags.ts
import { Flags } from "@lacspace/flags";

// Config — load from JSON / env / DB, hot-swap with flags.update(...)
export const flags = new Flags({
  "new-dashboard": { rollout: 25 },                              // 25% of users
  "beta": { rules: [{ when: { plan: "pro" }, value: true }] },   // pro users only
  "eu-feature": { rules: [{ when: { country: { in: ["DE", "FR"] } }, value: true }] },
  "checkout-exp": {                                              // A/B test
    type: "variant",
    variants: [{ key: "control", weight: 1 }, { key: "one-click", weight: 1 }],
  },
});

// Evaluate — synchronous, stable per user
flags.isEnabled("new-dashboard", { key: user.id });                       // boolean
flags.isEnabled("beta", { key: user.id, attributes: { plan: user.plan } });
flags.variant("checkout-exp", { key: user.id });                          // "control" | "one-click"

Exports 5

FlagsbucketisEnabledpercentagevariant

Keywords

feature-flagsfeature-togglefeature-flagab-testinga-b-testingexperiments

More in App & Utils Kit