Integrate FlagSync feature flags into web applications.
@flagsync/js-sdk
integrates into web applications for client-side feature management and event tracking—ideal for single-user contexts like browser environments.
key
in FsUserContext
is unique and persistent for accurate MAU tracking and consistent flag evaluations. See User Context Best Practices for details.Promises
Events
localstorage
storage type; the default is memory
.defaultValue
or control
:
flag()
returns the server-evaluated value:
LocalStorage
or an initial flag set—values apply until the SDK is ready.flag()
is called.track()
—use eventValue
for numeric data or properties
for rich context:
SDK_UPDATE
: Emitted when flags are updatedSDK_READY
: Emitted when the SDK is readySDK_READY_FROM_STORE
: Emitted when flags are loaded from storageERROR
: Emitted when an error occurs during initializationSDK_UPDATE
does not fire if syncing is disabled.FsServiceError
.FsConfig
interface:
key
in FsUserContext
is unique and persistent for accurate MAU tracking and consistent flag evaluations. See User Context Best Practices for details.sync
object: stream
, poll
, or off
.
Stream (Default)
Polling
Off
Memory (Default)
LocalStorage
SDK_READY_FROM_STORE
event fires when loading from LocalStorage—no network request needed, but data may be stale. stream
/poll
/off
) based on your application’s needs.FLAGSYNC_SDK_KEY
: Your client-side FlagSync SDK key (required)