Server TypeScript SDK
Evaluate typed flags locally on trusted servers with polling, ETag caching, and streaming invalidation.
The server TypeScript SDK is built for trusted server-side applications. It uses secret server runtime keys, keeps the latest snapshot in memory, evaluates locally, and returns caller-provided defaults before the first snapshot is ready. Use the Browser SDK or React SDK for publishable client-key evaluation in browser code.
A server runtime key reads your full flag snapshot — keep it on the server and load it from an environment variable. For browser code, use a publishable client key with the Browser SDK.
Create a client
Create one client per runtime key and reuse it for the lifetime of the process. Choose streaming for near-instant invalidation, or polling when a long-lived connection is not practical.
import { FeatureGateClient } from "@featuregate/server";
export const featuregate = new FeatureGateClient({
runtimeApiKey: process.env.FEATUREGATE_RUNTIME_KEY!,
syncMode: "streaming",
});
await featuregate.waitForReady({ timeoutMs: 2_000 });Evaluate flags
Every evaluation takes an explicit default, so a call site is well-defined even before the first snapshot arrives or if a flag is removed.
const enabled = featuregate.isEnabled("new-checkout", {
defaultValue: false,
attributes: {
user: { id: "user_123" },
account: { plan: "pro" },
},
});Testing & offline
For tests and local development, use offline and overrides so your app does not need a network call just to run a unit test. Call close() on shutdown to release the sync connection.
Call featuregate.close() when the process exits so the streaming connection and pending timers
are released. In tests, offline: true with overrides evaluates flags with no network at all.
Next steps
Evaluate client-exposed flags from the browser with publishable client keys.
Use FeatureGate from OpenFeature-compatible server-side JavaScript apps.
Model attributes, ordered rules, and stable percentage rollouts.
How auth failures, rate limits, and stale snapshots are handled.