@flaghoist/core
The evaluation engine behind Flaghoist. Flag schema, targeting rules, percentage rollouts, and the storage and auth interfaces the rest of the packages build on.
Zero dependencies, and no knowledge of HTTP or of where flags are stored.
You usually get this as a dependency of @flaghoist/server rather than installing it yourself.
Install it directly if you are writing a storage adapter, or if you want to evaluate flags in
process without running a server.
npm install @flaghoist/core
import { evaluate, createFlag } from '@flaghoist/core'
const flag = createFlag('new-checkout', {
enabled: true,
rollout: { percentage: 25 },
})
const result = evaluate(flag.flag, { targetingKey: 'user-123', plan: 'pro' })
// { value: true, reason: 'SPLIT', ... }
How evaluation works
Rules are ordered and the first match wins, with conditions inside a rule combined with AND. If no rule matches, the percentage rollout decides.
Rollouts bucket users with SHA-256 over the targeting key, so the same user always lands in the same place. Going from 10 percent to 20 percent adds people without reshuffling the ones already in.
Flags are boolean. There are no multivariate values, and evaluation returns a reason so you can tell why you got what you got.
Status
Beta. The core is feature-complete and ready for real projects. The API can still change before 1.0, and every breaking change is called out in the changelog, so pin your versions and read the notes when you upgrade. If something breaks, an issue is genuinely useful.
Apache-2.0. Part of Flaghoist.