Skip to main content
The JavaScript SDK is a framework-agnostic client for browsers and other JavaScript runtimes. It loads your configuration, evaluates flags locally, and stays subscribed for real-time updates.

Install

Initialize

Create a client with a client key (slc_). init returns immediately and starts loading in the background.
Flag reads work right away, returning your default value until the configuration is ready. To wait for the first load, await waitUntilReady:

Read a flag

Each flag type has a method. Pass the flag key, a subject key, attributes, and a default value.
Available methods:
  • getBooleanFlag(flagKey, subjectKey, attributes, defaultValue)
  • getStringFlag(flagKey, subjectKey, attributes, defaultValue)
  • getIntegerFlag(flagKey, subjectKey, attributes, defaultValue)
  • getNumericFlag(flagKey, subjectKey, attributes, defaultValue)
  • getJsonFlag<T>(flagKey, subjectKey, attributes, defaultValue)

React to changes

The client stays subscribed after the first load. Use subscribe to run code whenever flag values may have changed — re-read the flags you care about inside the listener.

Check status

getStatus reports the current load state as a discriminated union:

Clean up

Call close to tear down the subscription and release resources when the client is no longer needed.
Reads always return a value — your default until the configuration loads, and the resolved variation once it’s ready. You never need to guard a read against an unready client.