Node.js SDK
Server keys, per-request identity, and SSR state.
Cette page n’a pas encore de traduction française. Le texte anglais fait foi.
Last updated on
Node.js 22.5 or newer is required for node:sqlite. The SDK prefers optional better-sqlite3 and can fall back to node:sqlite.
@flagfix/node is the server SDK for APIs, workers, and SSR. It uses a server key and evaluate-all. Set apiHost to the FlagFix API. Never expose the server key to browsers.
import { createFlagFix, installShutdownHandlers } from "@flagfix/node";
const client = createFlagFix({
serverKey: process.env.FLAGFIX_SERVER_KEY!,
apiHost: process.env.FLAGFIX_API_HOST ?? "https://api.flagfix.io",
storage: { mode: "persistent" },
});
installShutdownHandlers({ client });
await client.start();withIdentity({ userId, anonymousId, traits }) returns a new client. Use it per request so concurrent users do not share one identity. exportFlagState() returns the current FlagState or null for React serverFlagState.
Defaults: evaluateMode: "server" (evaluate-all), SSE off, poll interval 0. Set flags.pollIntervalMs to poll. track accepts a string or { event, userId, properties }. An empty serverKey throws.
Cette page vous a-t-elle été utile ?