@stratal/feature-flags
v0.0.21
Published
Cloudflare Flagship feature flags for the Stratal framework — binding API wrapper with Inertia.js auto-sharing
Maintainers
Readme
@stratal/feature-flags
Cloudflare Flagship feature flags for the Stratal framework, using the native Worker binding API — with zero-config Inertia.js auto-sharing and typed React hooks.
Install
npm i @stratal/feature-flagsAdd the Flagship binding to your Wrangler config and run npx wrangler types:
// wrangler.jsonc
{ "flagship": [{ "binding": "FLAGS", "app_id": "<APP_ID>" }] }Usage
import { FeatureFlagModule } from '@stratal/feature-flags'
@Module({
imports: [
FeatureFlagModule.forRoot({
apps: [{ binding: 'FLAGS', flags: { 'new-checkout': false } }],
context: (ctx) => ({ userId: ctx.user().id }), // ctx.user() from @stratal/framework
}),
],
})
export class AppModule {}When @stratal/inertia is installed, declared flags are auto-shared to every Inertia page — no extra wiring.
Evaluate on the server:
const enabled = await this.flags.getBooleanValue('new-checkout') // uses manifest defaultRead on the client:
import { useFlag } from '@stratal/feature-flags/react'
const showNewCheckout = useFlag('new-checkout')See the framework docs for the full API.
License
MIT
