Any LaunchDarkly server SDK client that satisfies LDServerBaseClient.
The context to bind to this session. Typically resolved from the request (e.g. from auth tokens, cookies, or headers).
An LDServerSession scoped to the given context.
NOTE: We recommend using the createLDServerSession function to create your server session instead of directly calling this function.
This function is provided to allow the caller to have more control over handling their scoped LD client. If using this function, the caller is responsible for managing the lifecycle of the created wrapped client.
If called in a browser environment. This function must only be called on the server. Ensure the module that calls this is not imported from client components.
// lib/ld-server.ts
import { init } from '@launchdarkly/node-server-sdk';
import { createLDServerWrapper } from '@launchdarkly/react-sdk/server';
const ldBaseClient = await init(process.env.LAUNCHDARKLY_SDK_KEY || '');
export const serverSession = createLDServerWrapper(ldBaseClient, defaultContext);
Generated using TypeDoc
Creates a LaunchDarkly server SDK client that is scoped to a specific context.