Skip to main content

Use flags anywhere on the server

The SDK fetches configuration lazily, evaluates locally, and returns your fallback on operational failures. Constructor errors still throw immediately for developer mistakes such as a missing sdk_ key or invalid endpoint.

Global flags

Without an explicit context, evaluation uses { targetingKey: "server" }. That is appropriate for global flags. A percentage rollout will assign the whole service to one stable cohort.

Per-user or per-organization targeting

Use a stable logical identity. Only attributes in the environment privacy allow-list reach the evaluator.

Typed remote configuration

You can constrain keys at compile time:

Evaluation details

Details include evaluation provenance and bounded cache state. They never expose the API key or complete configuration.

Framework pattern

Keep the client outside the request handler:
This works for Next.js route handlers, traditional Node servers, serverless functions, workers, cron jobs, queues, and scripts. The package imports no Node built-ins, filesystem APIs, process hooks, or background intervals.

Refresh and diagnostics

Diagnostics are content-free: no credentials, contexts, evaluated values, or raw configuration. refresh() resolves with state instead of throwing.