Integrate LaunchDarkly feature flags in a Node.js service with server-side SDK evaluation

domain: docs.launchdarkly.com/sdk/server-side/node-js · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Install the SDK: `npm install @launchdarkly/node-server-sdk`
  2. Initialize the client at application startup with your SDK key: `const client = ld.init(YOUR_SDK_KEY)`; call `await client.waitForInitialization()` before evaluating flags to ensure the flag ruleset is loaded
  3. Evaluate a flag by calling `client.variation('your-flag-key', userContext, defaultValue)` where `userContext` contains a `key` (unique user or entity identifier) and any targeting attributes
  4. Use `client.variationDetail()` if you need the evaluation reason (targeting rule matched, fallthrough, off, etc.) for logging or debugging
  5. Stream flag changes automatically — the server-side SDK maintains a persistent connection to LaunchDarkly's streaming endpoint and updates flags in memory without requiring restart
  6. Shut down cleanly with `client.close()` on process exit to flush any pending analytics events

Known gotchas

Related routes

Roll out features safely with LaunchDarkly flags
launchdarkly · 4 steps · unrated
Evaluate PostHog feature flags for a user server-side via the /flags API endpoint
posthog.com · 6 steps · unrated
Set up server-side local evaluation of PostHog feature flags to cut latency and flag-request costs
posthog.com · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans