All official SDKs (Node.js, Browser, React, Next.js, NestJS) wrap a single FeatureFlagsClient from @clubedge/feature-flags-sdk-core. This page covers the configuration options, lifecycle methods, event model, and cache behavior shared across every SDK.
Installation
Packages are published to GitHub Packages. Configure your .npmrc:
The token needs read:packages scope. In CI, inject it as a masked secret.
@clubedge/feature-flags-sdk-core is a shared dependency of -node, -react, -nextjs, and -nestjs. Keep these packages’ versions in sync within a project to avoid type or runtime mismatches.
Configuration options
Every SDK accepts the same options object:
cacheTtlSeconds is actually in milliseconds. The config field is named cacheTtlSeconds but the value is passed directly to the cache as milliseconds (matching DEFAULT_CACHE_TTL_MS = 60_000). The default of 60000 works correctly as 60 seconds, but setting cacheTtlSeconds: 30 would yield a 30-millisecond TTL, not 30 seconds. Treat the value as milliseconds.
Lifecycle
client.initialize()
Fetches all flag configurations from GET /sdk/v1/config and populates the local in-memory cache. Starts background polling if pollIntervalMs > 0.
Must be called and awaited before any isEnabled() or getValue() call. Calling evaluation methods before initialization throws FeatureFlagsError with code NOT_INITIALIZED.
client.shutdown()
Stops the poll timer, clears pending requests, clears the in-memory cache, and emits a shutdown event.
client.isReady()
Returns true once initialize() has completed.
client.refresh()
Forces an immediate re-fetch of flag configurations from the server, bypassing the poll interval.
Evaluation methods
isEnabled(key, context?)
Returns true or false for the given flag key.
Context is evaluated at fetch time, not per-call. The SDK pre-evaluates all flags when fetching configs from GET /sdk/v1/config, using an empty context ({}). The context argument to isEnabled() is accepted for API compatibility but does not influence the result — it returns the cached pre-computed value.This means:
- Targeting rules that match on context attributes (e.g.
country == "US") will never match through the SDK, since the context is empty at evaluation time.
- Percentage rollouts that require
userId or tenantId will always fall through to the base flag value.
If you need per-user targeting or rollout evaluation, use Direct HTTP — POST /sdk/v1/evaluate — which evaluates with the full context you pass at request time. See Evaluation API.
getValue(key, context?)
Despite its name, getValue() returns the evaluation reason (a string), not the flag value.
Event model
The SDK emits lifecycle events. Provide a custom EventEmitter at construction or use the built-in one:
Cache behavior
The SDK uses a three-level cache:
Offline / failure behavior
Per-flag TTL override
When configuring a flag per environment via PUT /flags/:flagId/environments/:environmentId, you can set ttlOverrideSeconds to override the default SDK cache TTL for that specific flag/environment pair:
This is useful for kill-switch flags that need near-instant propagation.
Logger interface
ConsoleLogger — writes structured timestamps to stdout/stderr. debug() is a no-op in production (NODE_ENV=production).
NoOpLogger — silently discards all output (the default).