@lacspace/flags
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/flagsUsage
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
FlagsbucketisEnabledpercentagevariantKeywords
More in App & Utils Kit
A tiny in-memory cache — LRU eviction, per-entry TTL and stale-while-revalidate, plus wrap()/memoize() to cache any async function with in-flight de-duplication. Zero-dependency, isomorphic.
@lacspace/caseConvert strings between cases — camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE, Title Case, Sentence case. Handles acronyms & numbers. Zero-dependency, isomorphic.
@lacspace/colorParse, convert, manipulate and check colours — hex/rgb/hsl, lighten/darken/mix/alpha, and WCAG contrast for accessible palettes. Zero-dependency, isomorphic.
@lacspace/envTyped, validated environment variables — declare a schema, validate process.env at boot, get a typed frozen object or a clear fail-fast error. A zero-dependency t3-env / envalid alternative.
@lacspace/formEnd-to-end form handling for the server — turn FormData into typed, validated data with a honeypot + timing spam guard, and get back your data or per-field errors ready to re-render. Shaped for Next.js Server Actions. Zero-dependency, isomorphic.
@lacspace/humanizeTurn machine values into human-readable text — bytes, durations, relative time, ordinals, plurals, compact numbers and grammatical lists. Zero-dependency, isomorphic.