@configdirector/client-sdk
v1.10.1
Published
Javascript client SDK for ConfigDirector. ConfigDirector is a remote configuration and feature flag service.
Maintainers
Readme
ConfigDirector JavaScript Client SDK
JavaScript browser SDK for ConfigDirector, remote config and feature flags with typed values, JSON Schema validation, and safe renames of live flags. Start free, no card required.
Install
npm install --save @configdirector/client-sdkRetrieve a value
import { createClient } from "@configdirector/client-sdk";
const client = createClient("YOUR-CLIENT-SDK-KEY");
await client.initialize();
const darkMode = client.getValue("dark-mode", false);Full details are in the official documentation.
Test your code
@configdirector/client-sdk/testing creates a real client connected to an in-memory server that your
test controls, so the code under test runs against the production client without opening a network
connection or sending telemetry.
import { createTestClient } from "@configdirector/client-sdk/testing";
const testClient = createTestClient({ values: { "new-checkout": true } });
await testClient.client.initialize();
renderCheckout(testClient.client);
testClient.setValue("new-checkout", false);
testClient.removeValue("new-checkout");The test client also holds or fails initialize and updateContext (holdInitialization,
completeInitialization, failInitialization, and their ContextUpdate counterparts) so loading
and error states can be tested, and records every context in contextUpdates. Values keep their
type: a boolean, an integral number (integer), any other number (float), a string, or a plain
object or array (json), and reads behave exactly as they do against ConfigDirector. Under the test
client, initialize emits contextUpdated, then configsUpdated, then clientReady; a held
attempt that times out or is interrupted by pauseNetwork, dispose, or a new attempt leaves the
client not ready until the next attempt; and an exception thrown by a watcher during a delivery is
logged, as the production transports do.
Documentation
Refer to the official documentation for the JavaScript SDK.
There is also a quickstart guide for ConfigDirector and any of our SDKs.
