@netlify/launchdarkly-server-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.1.5 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @netlify/launchdarkly-server-sdk

Weekly Downloads

0

Version

0.1.5

License

ISC

Unpacked Size

2.65 MB

Total Files

7

Last publish

Collaborators

  • seanroberts
  • biilmann
  • eduardoboucas
  • netlify-bot
  • akardet
  • sarahetter
  • mikewen
  • kathmbeck
  • hrishikeshk
  • vitaliyr
  • denar90
  • smnh
  • berdav
  • youvalv
  • serhalp-netlify
  • orinokai