Skip to main content

Node SDK API reference

Current package: @superflag-sh/node@0.2.0.

createSuperflag(options)

endpoint and fetch are credential-bearing Interfaces: every configuration request passes the complete sdk_ bearer credential through them. Use only an HTTPS endpoint and a fetch implementation you control and trust. Never derive either option from a request, tenant, flag value, or other user-controlled input, and never log the request authorization header.

Read methods

isEnabled always uses false as its safe fallback. Other typed reads require an explicit fallback. Operational fetch, authorization, schema, and evaluation failures resolve to the fallback; they do not throw.

Lifecycle methods

Concurrent first reads and refreshes coalesce. The returned state is detached from the internal cache.

State

getState() returns status, optional source app/environment, config version, fetch/expiry/stale timestamps, and the last bounded error. Status is one of idle, ready, stale, or error.

Cache and network behavior

The client:
  • keeps configuration in memory only;
  • honors server TTL and opaque ETag revalidation;
  • serves last-known-good configuration only within maxStaleAgeSeconds;
  • rejects source identity changes and config-version rollback;
  • clears cached configuration immediately on 401 or 403;
  • honors bounded Retry-After behavior on 429; and
  • never persists keys, contexts, or raw configuration.
Both 200 and 304 advanced-config responses consume one environment config sync. A 304 renews freshness without response bytes.

Core helper versus networked SDK

@superflag-sh/core/node is a pure helper for code that already has a config. @superflag-sh/node owns authenticated synchronization, caching, failure policy, and diagnostics before delegating evaluation to core.