Node.js quickstart
Use the server SDK with Node.js 20 or later. Keep the server key in a secret environment variable. The SDK downloads your application's rules and evaluates flags in memory.
npm install @dipswitch/sdk-node
import { createClient } from '@dipswitch/sdk-node'
const serverKey = process.env.DIPSWITCH_SERVER_KEY
if (!serverKey) throw new Error('Set DIPSWITCH_SERVER_KEY')
const flags = createClient({ serverKey })
await flags.ready
export const useNewCheckout = (userId: string) => flags.isEnabled('new-checkout', userId, false)
export const stopFlags = () => flags.close()
Create one client for each application and environment used by your service, then reuse that client for every request. Close it on shutdown. A check uses the configured default if rules have not loaded or the flag is missing.