@nexusts/feature-flag
v0.9.6
Published
Feature flags, canary deployments, and A/B testing for NexusTS
Maintainers
Readme
@nexusts/feature-flag
Feature flags, canary deployments, and A/B testing for NexusTS.
Install
bun add @nexusts/feature-flagQuick start
import { FeatureFlagModule, FeatureFlagService, FeatureFlag } from '@nexusts/feature-flag';
@Module({
imports: [
FeatureFlagModule.forRoot({
flags: {
'new-dashboard': { enabled: true, rollout: 0.5 },
'beta-api': false,
},
}),
],
})
class AppModule {}
// In a controller:
const showBeta = await flags.isEnabled('new-checkout', { userId: 'u-1' });
// Or as a decorator:
@FeatureFlag('new-dashboard')
async index() { ... }API
| Method | Description |
| ------ | ----------- |
| isEnabled(flag, context?) | Promise<boolean> — true if the flag is active |
| setFlag(name, definition) | Add or update a flag at runtime |
| getFlag(name) | Return the current definition |
Flag evaluation order: denylist → allowlist → enabled: false →
rollout (djb2 hash) → default.
