> ## Documentation Index
> Fetch the complete documentation index at: https://launchdarkly.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

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

<View title="Developer" />

<View title="Federal docs" />

<View title="EU docs" />

This topic summarizes changes and explains how to adapt code that uses a 7.x version of the [Node.js (server-side) SDK](/docs/sdk/server-side/node-js) 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](https://github.com/launchdarkly/js-core/tree/main/packages/sdk/server-node) in GitHub.
* has a new [package name](https://www.npmjs.com/package/@launchdarkly/node-server-sdk).

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](https://launchdarkly.com/policies/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](https://github.com/nodejs/release#release-schedule).

## 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:

<CodeGroup>
  ```ts title="Node.js SDK v8.x" lines wrap theme={null}
  import * as ld from '@launchdarkly/node-server-sdk';

  const options: ld.LDOptions = {
    proxyOptions: {
        host: 'your-proxy-host',
        port: 8080,
        scheme: 'https',
        auth: 'username:password'
      }
  };
  ```

  ```ts title="Node.js SDK v7.x" lines wrap theme={null}
  import * as ld from 'launchdarkly-node-server-sdk';

  const options: ld.LDOptions = {
    proxyHost: 'your-proxy-host',
    proxyPort: 8080,
    proxyAuth: 'username:password'
  };
  ```
</CodeGroup>

To learn more, read [Web proxy configuration](/docs/sdk/features/web-proxy#node-js-server-side).

## Understanding changes to the Redis integration

The Redis integration package has a new [repository](https://github.com/launchdarkly/js-core/tree/main/packages/store/node-server-sdk-redis) and [package](https://www.npmjs.com/package/@launchdarkly/node-server-sdk-redis).

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`](https://github.com/redis/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:

<CodeGroup>
  ```js title="v8.0+ (JavaScript)" lines wrap theme={null}
  const ld = require('@launchdarkly/node-server-sdk');
  const RedisFeatureStore = require('@launchdarkly/node-server-sdk-redis');

  const store = RedisFeatureStore({
      redisOpts: { host: 'redis-host', port: 6379 },
      prefix: 'your-key-prefix',
      cacheTTL: 30,
  });

  const options = {
    featureStore: store
  };
  const client = ld.init(sdkKey, options);
  ```

  ```ts title="v8.0+ (TypeScript)" lines wrap theme={null}
  import * as ld from '@launchdarkly/node-server-sdk';
  import { RedisFeatureStore } from '@launchdarkly/node-server-sdk-redis';

  const store = RedisFeatureStore({
      redisOpts: { host: 'redis-host', port: 6379 },
      prefix: 'your-key-prefix',
      cacheTTL: 30,
  });

  const options: ld.LDOptions = {
    featureStore: store,
  };
  const client = ld.init('YOUR_SDK_KEY', options);
  ```

  ```js title="v7.x (JavaScript)" lines wrap theme={null}
  const ld = require('launchdarkly-node-server-sdk');
  const RedisFeatureStore = require('launchdarkly-node-server-sdk-redis');

  const redisOpts = {
    url: 'redis://your-redis:6379'
  };
  const store = RedisFeatureStore(redisOpts, 30, 'your-key-prefix');

  const options = {
    featureStore: store
  };
  const client = ld.init(sdkKey, options);
  ```

  ```ts title="v7.x (TypeScript)" lines wrap theme={null}
  import * as ld from 'launchdarkly-node-server-sdk';
  import { RedisFeatureStore } from 'launchdarkly-node-server-sdk-redis';

  const store = RedisFeatureStore({
      redisOpts: { host: 'redis-host', port: 6379 },
      prefix: 'your-key-prefix',
      cacheTTL: 30,
  });

  const options: ld.LDOptions = {
    featureStore: store,
  };
  const client = ld.init('YOUR_SDK_KEY', options);
  ```
</CodeGroup>

## Understanding changes to the DynamoDB integration

The DynamoDB integration package has a new [repository](https://github.com/launchdarkly/js-core/tree/main/packages/store/node-server-sdk-dynamodb) and [package](https://www.npmjs.com/package/@launchdarkly/node-server-sdk-dynamodb).

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`](https://github.com/aws/aws-sdk-js-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:

<CodeGroup>
  ```js title="v8.0+ (JavaScript)" lines wrap theme={null}
  const ld = require('@launchdarkly/node-server-sdk');
  const { DynamoDBFeatureStore } = require('@launchdarkly/node-server-sdk-dynamodb');

  const store = DynamoDBFeatureStore(
    'your-table',
    { cacheTTL: 30 }
  );

  const options = {
    featureStore: store
  };
  const client = ld.init('YOUR_SDK_KEY', options);
  ```

  ```ts title="v8.0+ (TypeScript)" lines wrap theme={null}
  import * as ld from '@launchdarkly/node-server-sdk';
  import { DynamoDBFeatureStore } from '@launchdarkly/node-server-sdk-dynamodb';

  const store = DynamoDBFeatureStore(
    'your-table',
    { cacheTTL: 30 }
  );

  const options: ld.LDOptions = {
    featureStore: store,
  };
  const client = ld.init('YOUR_SDK_KEY', options);
  ```

  ```js title="v7.x (JavaScript)" lines wrap theme={null}
  const ld = require('launchdarkly-node-server-sdk');
  const { DynamoDBFeatureStore } = require('launchdarkly-node-server-sdk-dynamodb');

  const store = DynamoDBFeatureStore('your-table', { cacheTTL: 30 });

  const options = {
    featureStore: store
  };
  const client = ld.init('YOUR_SDK_KEY', options);
  ```

  ```ts title="v7.x (TypeScript)" lines wrap theme={null}
  import * as ld from 'launchdarkly-node-server-sdk';
  import { DynamoDBFeatureStore } from 'launchdarkly-node-server-sdk-dynamodb';

  const store = DynamoDBFeatureStore(
    'your-table',
    { cacheTTL: 30 }
  );

  const options: ld.LDOptions = {
    featureStore: store,
  };
  const client = ld.init('YOUR_SDK_KEY', options);
  ```
</CodeGroup>

## 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:

<CodeGroup>
  ```js title="v8.0+ (JavaScript)" lines wrap theme={null}
  import { init } from '@launchdarkly/node-server-sdk';
  import { TestData } from '@launchdarkly/node-server-sdk/integrations';

  const td = new TestData();
  testData.update(td.flag('example-flag-key').booleanFlag().variationForAll(true));
  const client = init('YOUR_SDK_KEY', { updateProcessor: td.getFactory() });

  // flags can be updated at any time:
  td.update(td.flag('flag-key-456def')
      .variationForUser('example-user-key', true)
      .fallthroughVariation(false));

  ```

  ```js title="v7.x (JavaScript)" lines wrap theme={null}
  const { TestData } = require('launchdarkly-node-server-sdk/integrations');

  const td = TestData();
  testData.update(td.flag('example-flag-key').booleanFlag().variationForAllUsers(true));
  const client = new LDClient('YOUR_SDK_KEY', { updateProcessor: td });

  // flags can be updated at any time:
  td.update(td.flag('flag-key-456def')
      .variationForUser('example-user-key', true)
      .fallthroughVariation(false));

  ```
</CodeGroup>

## 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:

<CodeGroup>
  ```js title="v8.0+ (JavaScript)" lines wrap theme={null}
  const ld = require('@launchdarkly/node-server-sdk');
  const { FileDataSourceFactory } = require('@launchdarkly/node-server-sdk/integrations');

  const fileData = new FileDataSourceFactory({
    paths: [ 'file1.json', 'file2.json' ]
  });

  const options = {
    updateProcessor: fileData.getFactory()
  };

  const client = ld.init('YOUR_SDK_KEY', options);
  ```

  ```ts title="v8.0+ (TypeScript)" lines wrap theme={null}
  import * as ld from '@launchdarkly/node-server-sdk';
  const { FileDataSourceFactory } = require('@launchdarkly/node-server-sdk/integrations');

  const fileData = new FileDataSourceFactory({
    paths: [ 'file1.json', 'file2.json' ],
  });

  const options: ld.LDOptions = {
    updateProcessor: fileData.getFactory()
  };

  const client = ld.init('YOUR_SDK_KEY', options);
  ```

  ```js title="v7.x (JavaScript)" lines wrap theme={null}
  const ld = require('launchdarkly-node-server-sdk');
  const { FileDataSource } = require('launchdarkly-node-server-sdk/integrations');

  const dataSource = FileDataSource({
    paths: [ 'file1.json', 'file2.json' ]
  });

  const options = {
    updateProcessor: dataSource
  };

  const client = ld.init('YOUR_SDK_KEY', options);
  ```

  ```ts title="v7.x (TypeScript)" lines wrap theme={null}
  import * as ld from 'launchdarkly-node-server-sdk';
  const { FileDataSource } = require('launchdarkly-node-server-sdk/integrations');

  const dataSource = FileDataSource({
    paths: [ 'file1.json', 'file2.json' ],
  });

  const options: ld.LDOptions = {
    updateProcessor: dataSource
  };

  const client = ld.init('YOUR_SDK_KEY', options);
  ```
</CodeGroup>
