Skip to content

Feature flags in Node.js: SDKs compared, local evaluation and per-request context

How to use feature flags in Node.js: the Node SDKs of 18 tools with npm packages and evaluation modes, tested OpenFeature code with per-request context, startup and shutdown, and what to watch in Express or Fastify apps.

5 min read

Short answer: Most Node.js flag SDKs download the flag rules at startup and evaluate them in your process, so a flag check takes microseconds and keeps working if the flag service is briefly down. Initialize the SDK once at startup, wait until it's ready, pass the current user with each check, and close it on shutdown so pending events are sent.

Which Node.js SDKs are there, and how do they evaluate?

Package versions from npm and evaluation modes from each vendor's docs, checked on 15 November 2026.

Tool npm package How the Node SDK evaluates
OpenFeature @openfeature/server-sdk 1.23.0, plus a provider Depends on the provider
LaunchDarkly @launchdarkly/node-server-sdk 9.16.5 Locally, with the ruleset kept current over a streaming connection
Unleash unleash-client 6.12.2 Locally, refreshing every 15 seconds by default
GrowthBook @growthbook/growthbook 2.0.0 Locally, from cached feature definitions
Flagsmith @flagsmith/nodejs 9.4.0 (replaces flagsmith-nodejs) Remotely by default, one API request per call; local evaluation is opt-in and polls every 60 seconds
ConfigCat @configcat/sdk 1.1.0 (replaces configcat-node) Locally, from a config downloaded every 60 seconds by default
PostHog posthog-node 5.73.1 Remotely by default; local evaluation polls every 30 seconds
Statsig @statsig/statsig-node-core 0.24.2 (the legacy SDK is statsig-node) Locally after initialization, with background updates
DevCycle @devcycle/nodejs-server-sdk 1.56.1 Locally, with a WASM bucketing library; cloud bucketing (an API call per check) is optional
Split / Harness FME @splitsoftware/splitio 11.12.1 Locally, with changes pushed or polled
Optimizely @optimizely/optimizely-sdk 6.7.0 Locally, from a synced datafile
Reflag @reflag/node-sdk 1.8.3 Locally, with changes pushed over server-sent events
FeatBit @featbit/node-server-sdk 1.4.1 Locally, with changes over WebSocket or polling
Tggl tggl-client 3.2.2 Locally with the local client on Pro and above (polls every 5 seconds); otherwise remotely
Flipt @flipt-io/flipt-client-js 0.7.0 (replaces @flipt-io/flipt-client) Client-side evaluation with a WASM engine; polling by default, or streaming
flagd @openfeature/flagd-provider 0.18.0 Remote over gRPC (the default) or in-process, from flagd's sync stream or a local file
GO Feature Flag @openfeature/go-feature-flag-provider 2.2.0 In-process by default, or remote
Azure App Configuration @microsoft/feature-management 2.3.1, @azure/app-configuration-provider 2.6.0 Locally, from flags loaded into the app; updated when the app calls refresh()

Sources: each tool profile has an evaluation row with its source; package changes from Flagsmith server-side SDKs, ConfigCat Node.js, Statsig Node Core and the Flipt client SDK. AWS AppConfig has no Node SDK that evaluates flags: apps read them from the AppConfig Agent on localhost:2772, which also evaluates multi-variant rules, or fetch the configuration with @aws-sdk/client-appconfigdata or Powertools' AppConfig provider (AppConfig Agent, Powertools parameters).

Local evaluation is fast: in our latency benchmark, local checks with the Unleash, flagd and GO Feature Flag Node.js SDKs took microseconds, and remote checks a network round trip.

How do I pass the current user without threading it through every function?

In a web server, each request has a user. OpenFeature's transaction context stores it for the duration of the request using Node's AsyncLocalStorage, so code deep in your app can check flags without receiving the user as an argument. We ran this with @openfeature/server-sdk 1.23.0 and the flagd provider 0.18.0 reading a local file (no server needed):

import http from 'node:http'
import { OpenFeature, AsyncLocalStorageTransactionContextPropagator } from '@openfeature/server-sdk'
import { FlagdProvider } from '@openfeature/flagd-provider'

OpenFeature.setTransactionContextPropagator(new AsyncLocalStorageTransactionContextPropagator())
await OpenFeature.setProviderAndWait(
  new FlagdProvider({ resolverType: 'in-process', offlineFlagSourcePath: './flags.json' }),
)
const client = OpenFeature.getClient()

async function checkoutPage() {
  // No user passed in: the context comes from the current request
  return (await client.getBooleanValue('new-checkout', false)) ? 'New checkout' : 'Old checkout'
}

const server = http.createServer((req, res) => {
  const user = { targetingKey: req.headers['x-user-id'] ?? 'anonymous', plan: req.headers['x-plan'] ?? 'free' }
  OpenFeature.setTransactionContext(user, async () => {
    res.end(await checkoutPage())
  })
})

server.listen(3000)
process.on('SIGTERM', async () => {
  server.close()
  await OpenFeature.close()
})

With a flags.json whose new-checkout rule turns on for plan equal to pro, a request with x-plan: pro returned "New checkout" and one without it "Old checkout", and the process exited cleanly on SIGTERM. In Express, set the context in a middleware and continue the request inside the callback (setTransactionContext returns nothing, so it can't be awaited):

app.use(express.json())
app.use((req, res, next) => OpenFeature.setTransactionContext(contextFrom(req), next))

We tested this with Express 5.3 and its JSON body parser (body-parser 2.4): the route saw the user's context whether the middleware ran before or after express.json(). Still, async context can be lost when code continues from callbacks that aren't bound to it, such as raw request-stream events in older middleware (Node.js: troubleshooting context loss), so placing the context middleware after body parsing is the safer default. If flags unexpectedly return defaults in a route, check for lost context first. In Fastify, set it in a hook that runs after parsing, such as preHandler.

Use headers only as a demo: in a real app, take the user and plan from your session or database, not from headers the client controls.

What should I do at startup and shutdown?

  • Create one client per process, not per request: SDKs keep connections and caches.
  • Wait until it's ready before serving traffic, or decide to serve defaults. OpenFeature's setProviderAndWait waits, has no timeout of its own and rejects if the provider fails to start, which crashes a process using top-level await; wrap it, for example await Promise.race([OpenFeature.setProviderAndWait(provider), timeout(5000)]).catch(logError), or use the provider's own deadline option. Evaluations return defaults until the provider is ready.
  • Close on shutdown. OpenFeature.close() calls each provider's close, which stops polling or streams and, for vendor providers that send events, flushes them; vendor SDKs have their own close or flush methods.
  • Serverless functions start often and are frozen between invocations, without a shutdown signal unless an extension is registered. Flush events at the end of each invocation (for example PostHog's await client.shutdown() or LaunchDarkly's flush()) instead of relying on SIGTERM, and prefer SDKs or modes that start from a cached or bundled copy, or a relay or proxy close by (PostHog serverless, Lambda lifecycle). See feature flags in AWS Lambda for patterns and a freeze test.

What goes wrong in Node.js apps?

  • Remote evaluation on hot paths. Flagsmith and PostHog evaluate remotely by default; turn on local evaluation for flags checked on every request.
  • Deprecated packages. flagsmith-nodejs, configcat-node and @flipt-io/flipt-client carry npm deprecation notices pointing to their replacements.
  • A hung flag service. Remote checks can wait for a timeout; see what we measured in local vs remote evaluation.
  • Context leaking between requests. Don't store the current user in a module-level variable; pass it per call or use transaction context.

For other server languages, see feature flags in Python, Go and Java. For browser code, see feature flags in React and feature flags in Next.js. To pick a tool, see the best feature flag tools or the directory.