Web SDK reference

4 minute read

CloudBees Unify Feature Management SDKs for web platforms provide JavaScript integration for browser applications and server-side rendering environments. Use this reference when implementing feature flags in web applications or troubleshooting SDK integration issues.

Each reference covers SDK version 6.x. Refer to the CloudBees Unify changelog for version-specific differences.

JavaScript browser SDK methods

The JavaScript browser SDK provides the Rox object as the main interface for feature flag management in client-side web applications running in browsers.

Initialize the browser SDK (setup)

This method initializes the SDK with your application key and configuration options for browser environments.

Rox.setup(appKey, options)

Configures the SDK for browser operation and fetches feature flag configuration from CloudBees Unify. Returns a promise that resolves when configuration is retrieved.

Register flag containers (register)

This method registers flag containers to make feature flags available for configuration in the CloudBees Unify UI.

Rox.register(namespace, container)

Registers a container instance containing Flag, RoxString, and RoxNumber objects with CloudBees Unify. The namespace parameter groups related flags for organization.

Browser SDK configuration options

Configuration options control SDK behavior, logging, callback handling, and environment-specific settings for browser applications.

Parameter Type Description

version

String

JavaScript client version identifier.

debugLevel

String

SDK verbosity level. Accepts verbose for detailed logging.

configurationFetchedHandler

Function

Callback executed after configuration sync from CloudBees Unify.

impressionHandler

Function

Callback for flag value computation and evaluation events.

freeze

String

Default freeze level: untilLaunch or none. Default is none.

platform

String

Custom platform override for specialized browser environments.

logger

Object

Custom logger object to override default logging behavior.

dynamicPropertyRuleHandler

Function

Callback for property condition evaluation without prior configuration.

Proxy

Object

Network proxy configuration for SDK requests to CloudBees Unify.

fetchFunction

Function

A function with the standard Fetch API signature (url, options) ⇒ Promise<Response> for making network requests. When provided, the SDK uses this function instead of the default Axios implementation.

Display local flag overrides (showOverrides)

This method opens a debug UI for viewing and modifying flag values locally during development.

Rox.showOverrides(position)

Opens the flag override view with controls for testing different flag configurations. Position parameter controls where the debug UI appears on screen.

Clear cached flag values (unfreeze)

This method clears flag value caches to force immediate re-evaluation against current configuration.

Unfreezes all flags to return updated values without waiting for normal refresh cycles.

JavaScript SSR SDK methods

The JavaScript SSR SDK provides server-side rendering support for feature flag management in Node.js environments and universal JavaScript applications.

Initialize the SSR SDK (setup)

This method initializes the SDK with your application key and configuration options for server-side rendering environments.

import {Rox} from 'rox-ssr'; Rox.setup(appKey, options)

Configures the SDK for server-side operation and establishes connection to CloudBees Unify. Returns a promise that resolves when configuration is retrieved.

Register flag containers (register)

This method registers flag containers for server-side flag evaluation and configuration management.

import {RoxNumber, Flag, RoxString, Rox} from 'rox-ssr'; Rox.register(namespace, container)

Registers container instance containing server-side flag definitions with CloudBees Unify. Enables flag configuration through the CloudBees Unify UI for server-rendered content.

Set global evaluation context (setContext)

This method configures global context properties used for flag evaluation across all server requests.

Rox.setContext(context)

Sets static context properties that remain consistent across the server application lifecycle. Context properties enable advanced targeting and flag evaluation logic.

SSR SDK configuration options

Configuration options control server-side SDK behavior, including fetch intervals and callback handling for SSR environments.

Parameter Type Description

version

String

JavaScript server version identifier.

debugLevel

String

SDK verbosity level. Accepts verbose for detailed logging.

configurationFetchedHandler

Function

Callback executed after configuration sync from CloudBees Unify.

impressionHandler

Function

Callback for server-side flag evaluation events.

platform

String

Custom platform identifier for server environments.

fetchIntervalInSec

Number

Configuration refresh interval in seconds. Default: 60, minimum: 30.

Common JavaScript flag types

JavaScript SDKs support multiple flag types for different data types and use cases in both browser and server environments.

Flag (Boolean flags)

Boolean feature flags for on/off functionality and binary feature switches.

new Flag(defaultValue)

Creates a binary flag that returns true or false based on configuration and targeting rules. Default value determines the flag state when no configuration is available.

Flag methods

Methods available on Flag instances for value evaluation and status checking.

isEnabled()

Returns boolean true when the flag is enabled based on current configuration.

isEnabled(context)

Returns boolean true when the flag is enabled, using provided context for evaluation.

name

Returns the flag name (available only after registration).

RoxString (String flags)

String-based feature flags for text content, configuration values, and multi-variant testing.

new RoxString(defaultValue, variations)

Creates a string flag that returns one value from a predefined set of string variations. Supports A/B testing and gradual feature rollouts with different text content.

RoxString methods

Methods available on RoxString instances for value retrieval and configuration access.

getValue(context)

Returns the current string value accounting for configuration overrides and targeting rules.

name

Returns the flag name (available only after registration).

RoxNumber (Numeric flags)

Numeric feature flags for integers, configuration parameters, and gradual numeric rollouts.

new RoxNumber(defaultValue, variations)

Creates a numeric flag that returns one value from a predefined set of number variations. Enables gradual rollouts and A/B testing with different numeric parameters.

RoxNumber methods

Methods available on RoxNumber instances for value retrieval and configuration access.

getValue(context)

Returns the current numeric value accounting for configuration overrides and targeting rules.

name

Returns the flag name (available only after registration).

Local flag overrides

JavaScript SDKs provide override capabilities for local development and testing without affecting production configurations.

Set flag overrides (setOverride)

This method overrides flag values locally for development and testing purposes.

Rox.overrides.setOverride(flagName, value)

Sets a local override value that persists until explicitly cleared. Override values take precedence over CloudBees Unify configuration.

Clear flag overrides (clearOverride)

This method removes local override values to restore normal flag behavior.

Rox.overrides.clearOverride(flagName)

Clears the override value from local storage and resumes normal flag evaluation.

Check override status (hasOverride)

This method checks whether a flag currently has a local override in place.

Rox.overrides.hasOverride(flagName)

Returns true if the specified flag has an active local override value.

SDK lifecycle methods

Methods for managing SDK state, configuration updates, and cleanup operations.

Fetch updated configuration (fetch)

This method manually triggers a configuration update from CloudBees Unify.

Forces an immediate sync with CloudBees Unify to retrieve the latest flag configuration and targeting rules. Useful for ensuring up-to-date configuration without waiting for automatic refresh cycles.

Set custom properties

These methods define custom properties for advanced flag targeting and evaluation logic.

Custom properties enable sophisticated targeting based on user attributes, application state, and environmental conditions. Properties can be static values or dynamic functions computed at evaluation time.