CloudBees Feature Management Node.js SDK

6.0.8 · active · verified Sun Apr 19

The `rox-node` package is the Node.js SDK for CloudBees Feature Management (formerly Rollout.io), offering capabilities for defining and managing feature flags, remote configuration variables, and custom properties within Node.js applications. Currently stable at version 6.0.8, this SDK enables developers to control application features dynamically via the CloudBees Feature Management dashboard, facilitating controlled rollouts, A/B testing, and targeted user experiences. It is designed for enterprise-grade feature management, providing secure and scalable solutions for accelerating development and minimizing deployment risk. The package is updated regularly, with its latest version published approximately four months ago as of late 2025. Key differentiators include its focus on secure feature management, advanced target grouping, and integration with the CloudBees ecosystem, which caters to complex production environments by allowing dynamic control over features without requiring code redeployments.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates the asynchronous initialization of the `rox-node` SDK, registration of feature flags (boolean, string, and number types), and evaluation of these flags after setup. It emphasizes using environment variables for the SDK key and includes basic error handling.

import Rox from 'rox-node';

// Define your feature flags in a container object
const flags = {
  enableBetaFeature: new Rox.Flag(false), // Default value is false
  welcomeMessage: new Rox.RoxString('Hello, User!', ['Welcome!', 'Greetings!', 'Hello, User!']),
  discountPercentage: new Rox.RoxNumber(0, [0, 5, 10, 15])
};

async function initializeFeatureManagement() {
  const SDK_KEY = process.env.ROX_SDK_KEY ?? 'YOUR_DEFAULT_SDK_KEY'; // Securely get your SDK key

  if (SDK_KEY === 'YOUR_DEFAULT_SDK_KEY') {
    console.warn('WARNING: ROX_SDK_KEY environment variable not set. Using a default key which may not connect to your dashboard.');
  }

  // Register the flags with an optional namespace (empty string for global namespace)
  Rox.register('', flags);

  try {
    // Initialize the SDK - this connects to the CloudBees Feature Management server
    await Rox.setup(SDK_KEY, { /* Optional Rox options */ });
    console.log('CloudBees Feature Management SDK initialized successfully.');

    // Evaluate flags after initialization
    if (flags.enableBetaFeature.isEnabled()) {
      console.log('Beta feature is ENABLED!');
      // Logic for beta feature
    } else {
      console.log('Beta feature is DISABLED.');
    }

    console.log(`Welcome message: ${flags.welcomeMessage.getValue()}`);
    console.log(`Discount: ${flags.discountPercentage.getValue()}%`);

  } catch (error) {
    console.error('Failed to initialize CloudBees Feature Management SDK:', error);
    // Fallback logic if SDK fails to initialize
    console.log('Using local default values for flags.');
  }
}

initializeFeatureManagement();

view raw JSON →