For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Sign inTry it free
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
  • SDKs
    • SDK concepts
    • SDK features
    • Client-side SDKs
    • Server-side SDKs
      • .NET SDK reference
      • Apex SDK reference
      • C++ SDK reference
      • Erlang SDK reference
      • Go SDK reference
      • Haskell SDK reference
      • Java SDK reference
      • Lua SDK reference
      • Node.js SDK reference
        • Node.js (server-side) SDK 8.x to 9.0 migration guide
        • Node.js (server-side) SDK 7.x to 8.0 migration guide
        • Node.js (server-side) SDK 6.x to 7.0 migration guide
        • Node.js (server-side) SDK 5.x to 6.0 migration guide
      • PHP SDK reference
      • Python SDK reference
      • Ruby SDK reference
      • Rust SDK reference
    • AI SDKs
    • Edge SDKs
    • OpenFeature providers
    • Observability SDKs
    • Relay Proxy
Sign inTry it free
LogoLogo
On this page
  • Overview
  • Introducing @launchdarkly/node-server-sdk
  • Identifying Node.js versions for the 8.0 SDK
  • Understanding changes to configuration options
  • Understanding changes to the Redis integration
  • Understanding changes to the DynamoDB integration
  • Understanding changes to the TestData integration
  • Understanding changes to the FileData integration
SDKsServer-side SDKsNode.js SDK reference

Node.js (server-side) SDK 7.x to 8.0 migration guide

Was this page helpful?
Previous

Node.js (server-side) SDK 6.x to 7.0 migration guide

Next
Built with

Overview

This topic summarizes changes and explains how to adapt code that uses a 7.x version of the Node.js (server-side) SDK to use version 8.0 or later.

Version 8.0 includes several breaking changes.

Before you migrate to version 8.0, update to the latest 7.x version. Some of the changes that are mandatory in 8.0 were originally added in a 7.x version and made optional.

Introducing @launchdarkly/node-server-sdk

In version 8.0, we’ve introduced @launchdarkly/node-server-sdk as a replacement for launchdarkly-node-server-sdk.

In this new package, the Node.js (server-side) SDK:

  • has been re-written in Typescript.
  • has been moved to a new repository in GitHub.
  • has a new package name.

Most of the API has remained compatible with version 7.x.

Identifying Node.js versions for the 8.0 SDK

The 8.0 version of the SDK is compatible with Node.js versions 14 and higher. LaunchDarkly no longer supports older Node.js versions, as is documented in the End of Life policy.

LaunchDarkly also no longer supports some Node.js versions above 14 that are not long-term-support versions and have reached their end of life. To learn more, read the Node.js releases page.

Understanding changes to configuration options

The userKeysCapacity and userKeysFlushInterval were deprecated in 7.x and removed in 8.0. Use contextKeysCapacity and contextKeysFlushInterval instead.

The proxyHost, proxyPort, and proxyAuth options were removed in 8.0. Use proxyOptions instead.

Here’s how:

1import * as ld from '@launchdarkly/node-server-sdk';
2
3const options: ld.LDOptions = {
4 proxyOptions: {
5 host: 'your-proxy-host',
6 port: 8080,
7 scheme: 'https',
8 auth: 'username:password'
9 }
10};

To learn more, read Web proxy configuration.

Understanding changes to the Redis integration

The Redis integration package has a new repository and package.

Node.js (server-side) SDK 8.0 does not work with the 2.x or earlier version of the integration. It requires @launchdarkly/node-server-sdk-redis version 3.0 or higher.

In version 3.0 and higher of the Node.js SDK Redis integration, the ioredis package is used for Redis operations.

In version 3.0 the redisOpts setting of LDRedisOptions is the RedisOptions type from ioredis. If you were using this option, then be sure to migrate your redis settings to ioredis settings.

In version 3.0 the client setting of LDRedisOptions is the Redis type from ioredis. If you were using this option, then be sure to create an ioredis client instead of a redis client.

Basic configuration of the Redis integration:

1const ld = require('@launchdarkly/node-server-sdk');
2const RedisFeatureStore = require('@launchdarkly/node-server-sdk-redis');
3
4const store = RedisFeatureStore({
5 redisOpts: { host: 'redis-host', port: 6379 },
6 prefix: 'your-key-prefix',
7 cacheTTL: 30,
8});
9
10const options = {
11 featureStore: store
12};
13const client = ld.init(sdkKey, options);

Understanding changes to the DynamoDB integration

The DynamoDB integration package has a new repository and package.

Node.js (server-side) SDK 8.0 does not work with the 4.x or earlier version of the integration. It requires @launchdarkly/node-server-sdk-dynamodb version 5.0 or higher.

In version 5.0 and higher of the Node.js SDK DynamoDB integration, the AWS SDK for JavaScript v3 package is used for DynamoDB operations.

In version 5.0 the clientOptions setting of LDDynamoDBOptions is the DynamoDBClientConfig from @aws-sdk/client-dynamodb. If you were using this options, then be sure to migrate your settings to those used in the AWS SDK for JavaScript v3.

In version 5.0 the dynamoDBClient setting of LDDynamoDBOptions is the DynamoDBClient from @aws-sdk/client-dynamodb. If you were using this options, then be sure to migrate your client the version from the AWS SDK for JavaScript v3.

Basic configuration of the DynamoDB integration:

1const ld = require('@launchdarkly/node-server-sdk');
2const { DynamoDBFeatureStore } = require('@launchdarkly/node-server-sdk-dynamodb');
3
4const store = DynamoDBFeatureStore(
5 'your-table',
6 { cacheTTL: 30 }
7);
8
9const options = {
10 featureStore: store
11};
12const client = ld.init('YOUR_SDK_KEY', options);

Understanding changes to the TestData integration

In v8.0 the API for TestData has changed:

  • TestData is now a class, and you must construct it using new.
  • There is a new method, getFactory, to get the updated processor factory.

Here’s how:

1import { init } from '@launchdarkly/node-server-sdk';
2import { TestData } from '@launchdarkly/node-server-sdk/integrations';
3
4const td = new TestData();
5testData.update(td.flag('example-flag-key').booleanFlag().variationForAll(true));
6const client = init('YOUR_SDK_KEY', { updateProcessor: td.getFactory() });
7
8// flags can be updated at any time:
9td.update(td.flag('flag-key-456def')
10 .variationForUser('example-user-key', true)
11 .fallthroughVariation(false));

Understanding changes to the FileData integration

In v8.0 the API for FileDataSource API has changed:

  • FileDataSourceFactory is now a class, and you must construct it using new.
  • There is a new method, getFactory, to get the updated processor factory.

Here’s how:

1const ld = require('@launchdarkly/node-server-sdk');
2const { FileDataSourceFactory } = require('@launchdarkly/node-server-sdk/integrations');
3
4const fileData = new FileDataSourceFactory({
5 paths: [ 'file1.json', 'file2.json' ]
6});
7
8const options = {
9 updateProcessor: fileData.getFactory()
10};
11
12const client = ld.init('YOUR_SDK_KEY', options);