ConfigCat SDK for JavaScript SSR

8.5.3 · maintenance · verified Tue Apr 21

The `configcat-js-ssr` package provides an official ConfigCat SDK for integrating feature flags into Server-Side Rendered (SSR) JavaScript applications, such as those built with Nuxt.js or Vue.js. It allows developers to manage feature toggles remotely via the ConfigCat Dashboard, enabling the separation of releases from deployments and targeting specific user groups. Currently at version 8.5.3, this SDK is in maintenance mode, superseded by the unified ConfigCat SDK for JavaScript. It receives only critical security patches, with official support ending on August 31, 2026. Developers are strongly encouraged to migrate to the new unified SDK, which offers a consolidated experience for both browser and Node.js environments and removes the need for a separate SSR-specific SDK. Its key differentiator was its specialized focus on SSR environments, but this has been absorbed by the unified SDK.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the ConfigCat client, fetch a feature flag value for both a generic and a specific user, and dispose of the client.

import { getClient, User } from 'configcat-js-ssr';

// Replace with your actual SDK Key from the ConfigCat Dashboard
const SDK_KEY = process.env.CONFIGCAT_SDK_KEY ?? 'YOUR_SDK_KEY';

async function initializeAndFetchFeatureFlags() {
  if (SDK_KEY === 'YOUR_SDK_KEY') {
    console.warn('Please replace YOUR_SDK_KEY with your actual ConfigCat SDK Key.');
  }

  const configCatClient = getClient(SDK_KEY);

  // Example: Get a feature flag for a generic user
  const isMyAwesomeFeatureEnabled = await configCatClient.getValueAsync('isMyAwesomeFeatureEnabled', false);
  console.log(`'isMyAwesomeFeatureEnabled' for generic user: ${isMyAwesomeFeatureEnabled}`);

  if (isMyAwesomeFeatureEnabled) {
    console.log('Doing the new thing!');
  } else {
    console.log('Doing the old thing.');
  }

  // Example: Get a feature flag for a specific user
  const userObject = new User('some-user-id'); // User ID can be any unique string
  userObject.setEmail('user@example.com');
  userObject.setCustom('region', 'eu');

  const valueForSpecificUser = await configCatClient.getValueAsync('isMyAwesomeFeatureEnabled', false, userObject);
  console.log(`'isMyAwesomeFeatureEnabled' for user 'some-user-id': ${valueForSpecificUser}`);

  // Don't forget to close the client when done (e.g., on app shutdown)
  // This ensures resources are released, especially important in environments like serverless functions.
  configCatClient.dispose();
}

initializeAndFetchFeatureFlags();

view raw JSON →