@netlify/launchdarkly-server-sdk
v0.1.5
Published
test
Downloads
44
Maintainers
Keywords
Readme
Netlify LaunchDarkly SDK
The Netlify LaunchDarkly SDK is designed for use with Netlify. It follows the server-side LaunchDarkly model for multi-user contexts.
Install
# npm
npm i @netlify/launchdarkly-server-sdk
# yarn
yarn add @netlify/launchdarkly-server-sdk
Quickstart
Initialize the ldClient with your client side ID
import { init as initLD } from '@netlify/launchdarkly-server-sdk';
export default {
async fetch(request: Request, env: Bindings): Promise<Response> {
const clientSideID = 'test-client-side-id';
const flagKey = 'testFlag1';
const context = { kind: 'user', key: 'test-user-key-1' };
// init the ldClient, wait and finally evaluate
const client = initLD(clientSideID);
await client.waitForInitialization();
const flagValue = await client.variation(flagKey, context, false);
return new Response(`${flagKey}: ${flagValue}`);
},
};
Developing this SDK
# at js-core repo root
npm i && npm run build
# run tests
npm run test