Guides
How to use feature flags in Node.js
One process client, one identity per request.
Cette page n’a pas encore de traduction française. Le texte anglais fait foi.
Last updated on
import { createFlagFix, installShutdownHandlers } from "@flagfix/node";
const flagfix = createFlagFix({
serverKey: process.env.FLAGFIX_SERVER_KEY!,
apiHost: process.env.FLAGFIX_API_HOST!,
});
installShutdownHandlers({ client: flagfix });
await flagfix.start();
export function flagsFor(userId: string, plan: string) {
return flagfix.withIdentity({ userId, traits: { plan } });
}Call start() on the per-request client before hasFeature. Do not identify the shared client inside a request. shutdown is for process exit, not for the end of one request. flush is the per-request drain.
Cette page vous a-t-elle été utile ?