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

# SDK configuration

<View title="Developer" />

<View title="Federal docs" />

<View title="EU docs" />

This topic explains how to configure various LaunchDarkly SDKs. It gives code samples for each SDK that include different configuration examples. This feature is available for client-side, server-side, and edge SDKs.

## Customize the SDK

You can use the configuration feature to configure certain aspects of your SDK, including flush intervals, timeout periods, and client connect parameters.

You can disable the publication of events for testing purposes. We strongly recommend against disabling events for any other reason because many features depend on regularly receiving analytics events, including targeting rules, flag statuses, and the **Contexts** or **Users** lists. To learn more, read [Analytics events](/docs/sdk/concepts/events).

Details about each SDK's configuration are available in the SDK-specific sections below:

* [Client-side SDKs](#client-side-sdks)
* [Server-side SDKs](#server-side-sdks)
* [Edge SDKs](#edge-sdks)

## Client-side SDKs

This feature is available in the following client-side SDKs:

* [.NET (client-side)](#net-client-side)
* [Android](#android)
* [C++ (client-side)](#c-client-side)
* [Electron](#electron)
* [Flutter](#flutter)
* [iOS](#ios)
* [JavaScript](#javascript)
* [Node.js (client-side)](#nodejs-client-side)
* [React Native](#react-native)
* [Roku](#roku)
* [Vue](#vue)

### .NET (client-side)

<Accordion title="Expand .NET (client-side) code sample">
  <Note>
    **The .NET (client-side) SDK uses a mobile key**

    The .NET (client-side) SDK uses a mobile key. Keys are specific to each project and environment. They are available on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Note>

  This code sample shows you how to create a custom configuration object to pass custom parameters to the client. With it, we've configured the event queue flush frequency.

  You can configure `Configuration.Builder`:

  <CodeGroup>
    ```csharp title=".NET SDK v5.0+ (C#)" lines wrap theme={null}
    var config = Configuration
        .Builder("example-mobile-key", ConfigurationBuilder.AutoEnvAttributes.Enabled)
        .Events(Components.SendEvents().FlushInterval(TimeSpan.FromSeconds(2)))
        .Build();
    LdClient client = LdClient.Init(config, context, TimeSpan.FromSeconds(10));
    ```
  </CodeGroup>

  To learn more about the specific configuration options available in this SDK, read [`Configuration`](https://launchdarkly.github.io/dotnet-core/pkgs/sdk/client/api/LaunchDarkly.Sdk.Client.Configuration.html).
</Accordion>

### Android

<Accordion title="Expand Android code sample">
  <Note>
    **The Android SDK uses a mobile key**

    The Android SDK uses a mobile key. Keys are specific to each project and environment. They are available on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Note>

  In the Android SDK, most of the configuration properties are grouped into areas of functionality, each of which has its own builder class that is only available if you are using that functionality. The basic areas of functionality are [data source](https://launchdarkly.github.io/android-client-sdk/com/launchdarkly/sdk/android/LDConfig.Builder.html#dataSource\(com.launchdarkly.sdk.android.subsystems.ComponentConfigurer\)), [events](https://launchdarkly.github.io/android-client-sdk/com/launchdarkly/sdk/android/LDConfig.Builder.html#events\(com.launchdarkly.sdk.android.subsystems.ComponentConfigurer\)), [networking](https://launchdarkly.github.io/android-client-sdk/com/launchdarkly/sdk/android/LDConfig.Builder.html#http\(com.launchdarkly.sdk.android.subsystems.ComponentConfigurer\)), and [service URIs](https://launchdarkly.github.io/android-client-sdk/com/launchdarkly/sdk/android/LDConfig.Builder.html#serviceEndpoints\(com.launchdarkly.sdk.android.integrations.ServiceEndpointsBuilder\)).

  This code sample shows you how to configure the client connect and flush interval parameters:

  <CodeGroup>
    ```java title="Java" lines wrap theme={null}
    LDConfig ldConfig = new LDConfig.Builder(AutoEnvAttributes.Enabled)
        .mobileKey("example-mobile-key")
        .http(
          Components.httpConfiguration()
          .connectTimeoutMillis(5000)
        )
        .events(
          Components.sendEvents()
          .flushIntervalMillis(5000)
        )
        .build();
    ```

    ```kotlin title="Kotlin" lines wrap theme={null}
    val ldConfig: LDConfig = LDConfig.Builder(AutoEnvAttributes.Enabled)
        .mobileKey("example-mobile-key")
        .http(
          Components.httpConfiguration()
          .connectTimeoutMillis(5000)
        )
        .events(
          Components.sendEvents()
          .flushIntervalMillis(5000)
        )
        .build();
    ```
  </CodeGroup>

  To learn more about the specific configuration options available in this SDK, read [`LDConfig.Builder`](https://launchdarkly.github.io/android-client-sdk/com/launchdarkly/sdk/android/LDConfig.Builder.html).
</Accordion>

### C++ (client-side)

<Accordion title="Expand C++ (client-side) code sample">
  <Note>
    **The C++ (client-side) SDK uses a mobile key**

    The C++ (client-side) SDK uses a mobile key. Keys are specific to each project and environment. They are available on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Note>

  This code sample shows you how to configure the event queue capacity and flush interval parameters:

  <CodeGroup>
    ```cpp title="C++ SDK v3.0 (native)" lines wrap theme={null}
    auto config_builder = client_side::ConfigBuilder("example-mobile-key");
    config_builder.Events()
        .Capacity(1000)
        .FlushInterval(std::chrono::seconds(30));
    auto config = config_builder.Build();
    if (!config) {
        /* an error occurred, config is not valid */
    }
    ```

    ```c title="C++ SDK v3.0 (C binding)" lines wrap theme={null}
    LDClientConfigBuilder builder = LDClientConfigBuilder_New("example-mobile-key");
    LDClientConfigBuilder_Events_Capacity(builder, 1000);
    LDClientConfigBuilder_Events_FlushIntervalMs(builder, 30 * 1000);
    LDClientConfig config;

    LDStatus status = LDClientConfigBuilder_Build(builder, &config);

    if (!LDStatus_Ok(status)) {
        /* an error occurred, config is not valid */
    }
    ```
  </CodeGroup>

  To learn more about the specific configuration options available in this SDK, read [`ConfigBuilder`](https://launchdarkly.github.io/cpp-sdks/libs/client-sdk/docs/html/classlaunchdarkly_1_1config_1_1shared_1_1builders_1_1ConfigBuilder.html). To learn more about the event queue capacity and flush interval parameters specifically, read [`EventsBuilder`](https://launchdarkly.github.io/cpp-sdks/libs/client-sdk/docs/html/classlaunchdarkly_1_1config_1_1shared_1_1builders_1_1EventsBuilder.html).
</Accordion>

### Electron

<Accordion title="Expand Electron code sample">
  <Warning>
    **Electron SDK credentials**

    The Electron SDK requires a client-side ID. Client-side IDs are specific to each project and environment. They are not secret, and you can include them in client-side code. Do not embed a server-side SDK key in a client-side application. You can find client-side IDs and project keys on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).

    If you connect the Electron SDK to the `ldcli` dev-server for local testing, use your **project key** instead of a client-side ID. Set all service endpoints to `http://localhost:8765`. If you use a client-side ID, the SDK connects to LaunchDarkly rather than the dev-server, which can produce CORS errors (especially from the renderer process).
  </Warning>

  This code sample shows you how to create a custom configuration object to pass custom parameters to the client:

  <CodeGroup>
    ```js title="JavaScript" lines wrap theme={null}
    const options = {
      allAttributesPrivate: true
    };
    const client = LDElectron.initializeInMain('example-client-side-id', user, options);

    ```

    ```ts title="TypeScript" lines wrap theme={null}
    import * as LDElectron from 'launchdarkly-electron-client-sdk'

    const options: LDElectron.LDOptions = { allAttributesPrivate: true };
    const client = LDElectron.initializeInMain('example-client-side-id', user, options);
    ```
  </CodeGroup>

  To learn more about the specific configuration options available in this SDK, read [`LDOptions`](https://launchdarkly.github.io/electron-client-sdk/interfaces/_launchdarkly_electron_client_sdk_.ldoptions.html).
</Accordion>

### Flutter

<Accordion title="Expand Flutter code sample">
  <Warning>
    **Flutter SDK credentials**

    The Flutter SDK v4 uses either a **mobile key** or a **client-side ID**, depending on your target platform. For Windows, macOS, Linux, Android, or iOS, use a mobile key. For **web builds**, use a client-side ID.

    You can find client-side IDs, mobile keys, and project keys on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).

    If you connect a **Flutter web** app to the `ldcli` dev-server for local testing, use your **project key** instead of a client-side ID, and set all service endpoints to `http://localhost:8765`. If you use a mobile key or client-side ID, the app connects to LaunchDarkly rather than the dev-server, which can result in CORS errors.
  </Warning>

  The Flutter SDK version 4 uses either a mobile key or a client-side ID, depending on the platform that you build for. You can set these in the `LAUNCHDARKLY_MOBILE_KEY` and `LAUNCHDARKLY_CLIENT_SIDE_ID` environment variables, and then use the `CredentialSource` helper to select your credential and provide it to your configuration. `CredentialSource` expects one of the two environment variables to be set, but not both.

  This code sample shows you how to configure the credential, automatic environment attributes, and evaluation reasons options:

  <CodeGroup>
    ```dart title="Flutter SDK v4" lines wrap theme={null}
    final config = LDConfig(
      CredentialSource.fromEnvironment(),
      AutoEnvAttributes.enabled,
      dataSourceConfig: DataSourceConfig(
        evaluationReasons: true
      ),
    );
    ```
  </CodeGroup>

  The credential and automatic environment attributes configuration options are required. All other configuration options are optional and use default values if not set.

  To learn more about the specific configuration options available in this SDK, read [`LDConfig`](https://pub.dev/documentation/launchdarkly_flutter_client_sdk/latest/launchdarkly_flutter_client_sdk/LDConfig-class.html).
</Accordion>

### iOS

<Accordion title="Expand iOS code sample">
  <Note>
    **The iOS SDK uses a mobile key**

    The iOS SDK uses a mobile key. Keys are specific to each project and environment. They are available on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Note>

  This code sample shows you how to configure the client connection timeout and event flush interval parameters:

  <CodeGroup>
    ```swift title="Swift" lines wrap theme={null}
    var ldConfig = LDConfig(mobileKey: "example-mobile-key", autoEnvAttributes: .enabled)
    ldConfig.connectionTimeout = 10.0
    ldConfig.eventFlushInterval = 30.0
    ```

    ```objectivec title="Objective-C" lines wrap theme={null}
    LDConfig *ldConfig = [[LDConfig alloc] initWithMobileKey:@"example-mobile-key" autoEnvAttributes:AutoEnvAttributesEnabled];
    ldConfig.connectionTimeout = 10.0;
    ldConfig.eventFlushInterval = 30.0;
    ```
  </CodeGroup>

  To learn more about the specific configuration options available in this SDK, read [`LDConfig`](https://launchdarkly.github.io/ios-client-sdk/Structs/LDConfig.html).
</Accordion>

### JavaScript

<Accordion title="Expand JavaScript code sample">
  <Warning>
    **JavaScript SDK credentials**

    The JavaScript SDK requires a client-side ID. Client-side IDs are specific to each project and environment. They are not secret, and you can include them in client-side code. Do not embed a server-side SDK key in a client-side application. You can find client-side IDs and project keys on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).

    If you connect the JavaScript SDK to the `ldcli` dev-server for local testing, use your project key instead of a client-side ID. Set all service endpoints to `http://localhost:8765`. If you use a client-side ID, the SDK connects to LaunchDarkly rather than the dev-server, which can result in CORS errors.
  </Warning>

  This code sample shows you how to create a custom configuration object to pass custom parameters to the client:

  <Warning>
    **The initialization method changed in v4.0 of the JavaScript SDK**

    Version 4.0 of the JavaScript SDK does not use the `initialize` method from earlier versions. To learn more, read [Client initialization](/docs/sdk/client-side/javascript/migration-3-to-4#client-initialization).
  </Warning>

  <CodeGroup>
    ```js title="JavaScript SDK v4.x" lines wrap theme={null}
    const options = { allAttributesPrivate: true };
    const client = createClient('example-client-side-id', context, options);
    client.start();

    const result = await client.waitForInitialization({ timeout: 5 });
    if (result.status === 'complete') {
    // Client initialized successfully
    } else if (result.status === 'failed') {
    // Client failed to initialize
    console.error('Initialization failed:', result.error);
    } else if (result.status === 'timeout') {
    // Initialization timed out
    console.error('Initialization timed out');
    }
    ```

    ```js title="JavaScript SDK v3.x" lines wrap theme={null}
    const options = { allAttributesPrivate: true };
    const client = LDClient.initialize('example-client-side-id', context, options);

    try {
    await client.waitForInitialization(5);
    proceedWithSuccessfullyInitializedClient();
    } catch(err) {
    // Client failed to initialize or timed out
    // variation() calls return fallback values until initialization completes
    }
    ```

    ```ts title="JavaScript SDK v3.x (TypeScript)" lines wrap theme={null}
    import * as LDClient from 'launchdarkly-js-client-sdk';

    const options: LDClient.LDOptions = { allAttributesPrivate: true };
    const client = LDClient.initialize('example-client-side-id', context, options);
    ```
  </CodeGroup>

  To learn more about the specific configuration options available in this SDK, read [`LDOptions`](https://launchdarkly.github.io/js-core/packages/sdk/browser/docs/interfaces/LDOptions.html).
</Accordion>

### Node.js (client-side)

<Accordion title="Expand Node.js (client-side) code sample">
  <Warning>
    **Node.js (client-side) SDK credentials**

    The Node.js (client-side) SDK requires a client-side ID. Client-side IDs are specific to each project and environment. They are not secret, and you can include them in client-side code. Do not embed a server-side SDK key in a client-side application. You can find client-side IDs and project keys on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).

    If you connect the Node.js (client-side) SDK to the `ldcli` dev-server for local testing, use your **project key** instead of a client-side ID. Set all service endpoints to `http://localhost:8765`. If you use a client-side ID, the SDK connects to LaunchDarkly rather than the dev-server, which can result in CORS errors.
  </Warning>

  This code sample shows you how to create a custom configuration object to pass custom parameters to the client:

  <CodeGroup>
    ```js title="Node.js SDK v3.0 (JavaScript)" lines wrap theme={null}
    const options = {
      flushInterval: 10000, // milliseconds
      allAttributesPrivate: true
    };

    const client = LDClient.initialize('example-client-side-id', context, options);
    try {
      await client.waitForInitialization(5);
      // initialization succeeded, flag values are now available
    } catch (err) {
      // initialization failed or did not complete before timeout
    }
    ```

    ```ts title="Node.js SDK v3.0 (TypeScript)" lines wrap theme={null}
    import * as LDClient from 'launchdarkly-node-client-sdk';

    const options: LDClient.LDOptions = {
      flushInterval: 10000, // milliseconds
      allAttributesPrivate: true,
    };
    const client = LDClient.initialize('example-client-side-id', context, options);
    try {
      await client.waitForInitialization(5);
      // initialization succeeded, flag values are now available
    } catch (err) {
      // initialization failed or did not complete before timeout
    }
    ```
  </CodeGroup>

  To learn more about the specific configuration options available in this SDK, read [`LDOptions`](https://launchdarkly.github.io/node-client-sdk/interfaces/LDOptions.html).
</Accordion>

### React Native

<Accordion title="Expand React Native code sample">
  <Note>
    **The React Native SDK uses a mobile key**

    The React Native SDK uses a mobile key. Keys are specific to each project and environment. They are available on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Note>

  This code sample shows you how to create a configuration object to pass configuration parameters to the client.

  The configuration object can include a variety of options. In version 10 of the SDK, all properties are optional.

  In versions 9 and earlier, `mobileKey` was a required property, but all other properties were optional. Additionally, in versions 9 and earlier we recommend setting a timeout parameter when you call `configure`. If the client receives flag values before the timeout, the returned promise will resolve. Otherwise, it will be rejected.

  <Warning>
    **Always include a timeout parameter in v9 and earlier when calling configure**

    In versions 9 and earlier, do not configure your SDK to initialize without a timeout parameter. Doing so will cause your app never to load if there is a connectivity problem. We recommend setting a timeout for no more than 1-5 seconds. To learn more, read [React Native SDK reference](/docs/sdk/client-side/react/react-native).
  </Warning>

  Here is an example:

  <CodeGroup>
    ```ts title="React Native SDK v10" lines wrap theme={null}
    import { type LDOptions } from '@launchdarkly/react-native-client-sdk';

    const options = {
      withReasons: true,
    };

    const client = new ReactNativeLDClient('example-mobile-key', AutoEnvAttributes.Enabled, options);
    ```
  </CodeGroup>

  To learn more about the specific configuration options available in this SDK, read [`LDOptions`](https://launchdarkly.github.io/js-core/packages/sdk/react-native/docs/interfaces/LDOptions.html).
</Accordion>

### Roku

<Accordion title="Expand Roku code sample">
  <Note>
    **The Roku SDK uses a mobile key**

    The Roku SDK uses a mobile key. Keys are specific to each project and environment. They are available on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Note>

  This code sample shows you how to create a configuration object:

  <CodeGroup>
    ```brightscript title="BrightScript" lines wrap theme={null}
    ' for a legacy Roku application
    config = LaunchDarklyConfig("example-mobile-key")

    ' for a SceneGraph Roku Application
    config = LaunchDarklyConfig("example-mobile-key", CLIENT_SCENEGRAPH_NODE)

    ```
  </CodeGroup>

  We support the following configuration options for both SceneGraph and non-SceneGraph usage:

  <CodeGroup>
    ```brightscript title="BrightScript" expandable lines wrap theme={null}
    config.setAppURI(String)

    config.setEventsURI(String)

    config.setStreamURI(String)


    config.setPollingIntervalSeconds(Integer)

    config.setOffline(Boolean)


    config.addPrivateAttribute(String)

    config.setAllAttributesPrivate(Boolean)


    config.setEventsCapacity(Integer)

    config.setEventsFlushIntervalSeconds(Integer)


    config.setLogger(Object)

    config.setLoggerNode(Dynamic)

    config.setStoreBackend(Object)

    config.setStoreBackendNode(Dynamic)


    config.setStreaming(Boolean)

    config.setLogLevel(Integer)


    config.setUseEvaluationReasons(Boolean)

    config.setApplicationInfoValue(String, String)
    ```
  </CodeGroup>
</Accordion>

### Vue

<Accordion title="Expand Vue code sample">
  The Vue SDK passes configuration options through to the underlying JavaScript SDK. Set them in the `ldOptions` property when you install the plugin or create a provider.

  Options that control the Vue integration itself, including `deferInitialization`, `startOptions`, `bootstrap`, and `injectionKey`, are top-level properties rather than part of `ldOptions`.

  To learn more, read [`LDVuePluginOptions`](https://launchdarkly.github.io/js-core/packages/sdk/vue/docs/interfaces/LDVuePluginOptions.html).

  Here is an example of each:

  <CodeGroup>
    ```ts title="Vue SDK v3.0, plugin" lines wrap theme={null}
    import { createApp } from 'vue'
    import { LDVuePlugin } from '@launchdarkly/vue-client-sdk'
    import App from './App.vue'

    createApp(App)
      .use(LDVuePlugin, {
        clientSideID: 'example-client-side-id',
        context: { kind: 'user', key: 'example-context-key' },
        // Options that control the Vue integration are top-level:
        startOptions: { timeout: 5 },
        // Options for the underlying JavaScript SDK go in `ldOptions`:
        ldOptions: {
          allAttributesPrivate: true,
          streaming: true
        }
      })
      .mount('#app')
    ```

    ```ts title="Vue SDK v3.0, provider" lines wrap theme={null}
    import { createLDProvider } from '@launchdarkly/vue-client-sdk'

    export const LDProvider = createLDProvider(
      'example-client-side-id',
      { kind: 'user', key: 'example-context-key' },
      {
        startOptions: { timeout: 5 },
        ldOptions: {
          allAttributesPrivate: true,
          streaming: true
        }
      }
    )
    ```
  </CodeGroup>
</Accordion>

## Server-side SDKs

This feature is available for the following server-side SDKs:

* [.NET (server-side)](#net-server-side)
* [Apex](#apex)
* [C++ (server-side)](#c-server-side)
* [Erlang](#erlang)
* [Go](#go)
* [Haskell](#haskell)
* [Java](#java)
* [Lua](#lua)
* [Node.js (server-side)](#nodejs-server-side)
* [PHP](#php)
* [Python](#python)
* [Ruby](#ruby)
* [Rust](#rust)

### .NET (server-side)

<Accordion title="Expand .NET (server-side) code sample">
  <Note>
    **The .NET (server-side) SDK uses an SDK key**

    The .NET (server-side) SDK uses an SDK key. Keys are specific to each project and environment. They are available on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Note>

  This code sample shows you how to pass custom parameters to the client by creating a custom configuration object:

  <CodeGroup>
    ```csharp title="C#" lines wrap theme={null}
    var config = Configuration.Builder("YOUR_SDK_KEY")
        .Events(
            Components.SendEvents().FlushInterval(TimeSpan.FromSeconds(2))
        )
        .StartWaitTime(TimeSpan.FromSeconds(5))
        .Build();
    var client = new LdClient(config);
    ```
  </CodeGroup>

  To learn more about the specific configuration that are available in this SDK, read [`ConfigurationBuilder`](https://launchdarkly.github.io/dotnet-core/pkgs/sdk/server/api/LaunchDarkly.Sdk.Server.ConfigurationBuilder.html).
</Accordion>

### Apex

<Accordion title="Expand Apex code sample">
  This code sample shows you how to configure the client to redact all user attributes in events:

  <CodeGroup>
    ```java title="Apex" lines wrap theme={null}
    LDConfig config = new LDConfig.Builder()
        .setAllAttributesPrivate(true)
        .build();
    ```
  </CodeGroup>

  To learn more about the specific configuration options available for this SDK, read [`LDConfig.Builder`](https://github.com/launchdarkly/apex-server-sdk/blob/master/doc.md#class-ldconfigbuilder).
</Accordion>

### C++ (server-side)

<Accordion title="Expand C++ (server-side) code sample">
  <Note>
    **The C++ (server-side) SDK uses an SDK key**

    The C++ (server-side) SDK uses an SDK key. Keys are specific to each project and environment. They are available on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Note>

  This code sample shows you how to configure the event queue capacity and flush interval parameters:

  <CodeGroup>
    ```cpp title="C++ SDK v3.0 (native)" lines wrap theme={null}
    auto config_builder = server_side::ConfigBuilder("YOUR_SDK_KEY");
    config_builder.Events()
        .Capacity(1000)
        .FlushInterval(std::chrono::seconds(30));
    auto config = config_builder.Build();
    if (!config) {
        /* an error occurred, config is not valid */
    }
    ```

    ```c title="C++ SDK v3.0 (C binding)" lines wrap theme={null}
    LDServerConfigBuilder builder = LDServerConfigBuilder_New("YOUR_SDK_KEY");
    LDServerConfigBuilder_Events_Capacity(builder, 1000);
    LDServerConfigBuilder_Events_FlushIntervalMs(builder, 30 * 1000);
    LDServerConfig config;

    LDStatus status = LDServerConfigBuilder_Build(builder, &config);

    if (!LDStatus_Ok(status)) {
        /* an error occurred, config is not valid */
    }
    ```
  </CodeGroup>

  To learn more about the specific configuration options available for this SDK, read [`ConfigBuilder`](https://launchdarkly.github.io/cpp-sdks/libs/server-sdk/docs/html/classlaunchdarkly_1_1config_1_1shared_1_1builders_1_1ConfigBuilder.html). To learn more about the event queue capacity and flush interval parameters specifically, read [`EventsBuilder`](https://launchdarkly.github.io/cpp-sdks/libs/server-sdk/docs/html/classlaunchdarkly_1_1config_1_1shared_1_1builders_1_1EventsBuilder.html).
</Accordion>

### Erlang

<Accordion title="Expand Erlang code sample">
  <Note>
    **The Erlang SDK uses an SDK key**

    The Erlang SDK uses an SDK key. Keys are specific to each project and environment. They are available on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Note>

  This code sample shows you how to pass custom parameters when the client starts with the `Options` map parameter. The code in this example turns off streaming, so the SDK connects to LaunchDarkly through polling.

  To pass custom parameters:

  <CodeGroup>
    ```erlang title="Erlang" lines wrap theme={null}
    % Specify options
    ldclient:start_instance("YOUR_SDK_KEY", #{stream => false})

    % With a custom instance name
    ldclient:start_instance("YOUR_SDK_KEY", your_instance, #{stream => false})
    ```
  </CodeGroup>

  To learn more about the specific configuration options available for this SDK, read [`ldclient_config`](https://hexdocs.pm/launchdarkly_server_sdk/ldclient_config.html).
</Accordion>

### Go

<Accordion title="Expand Go code sample">
  <Note>
    **The Go SDK uses an SDK key**

    The Go SDK uses an SDK key. Keys are specific to each project and environment. They are available on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Note>

  This code sample shows you how to pass custom parameters to the client by creating a custom configuration object. The code in this sample configures the event flush interval parameter.

  To pass custom parameters:

  <CodeGroup>
    ```go title="Go SDK v6+" lines wrap theme={null}
    import (
        "time"

        ld "github.com/launchdarkly/go-server-sdk/v6"
        "github.com/launchdarkly/go-server-sdk/v6/ldcomponents"
    )

    var config ld.Config

    config.Events = ldcomponents.SendEvents().FlushInterval(10*time.Second)

    client, _ := ld.MakeCustomClient("YOUR_SDK_KEY", config, 5*time.Second)
    ```
  </CodeGroup>

  To learn more about the specific configuration options available for this SDK, read [`Config`](https://pkg.go.dev/github.com/launchdarkly/go-server-sdk/v7#Config).
</Accordion>

### Haskell

<Accordion title="Expand Haskell code sample">
  <Note>
    **The Haskell SDK uses an SDK key**

    The Haskell SDK uses an SDK key. Keys are specific to each project and environment. They are available on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Note>

  This code sample shows you how to pass custom parameters to the client by creating a custom configuration object. This example configures the event queue capacity and flush interval parameters.

  To pass custom parameters:

  <CodeGroup>
    ```haskell title="Haskell" lines wrap theme={null}
    {-# LANGUAGE OverloadedStrings #-}

    import LaunchDarkly.Server.Config

    import Data.Function ((&))

    config :: Config
    config = (makeConfig "YOUR_SDK_KEY")
        & configSetEventsCapacity 1000
        & configSetFlushIntervalSeconds 30
    ```
  </CodeGroup>

  To learn more about the specific configuration properties that are available in this SDK, read [`Config`](https://launchdarkly.github.io/haskell-server-sdk/LaunchDarkly-Server-Config.html).
</Accordion>

### Java

<Accordion title="Expand Java code sample">
  <Note>
    **The Java SDK uses an SDK key**

    The Java SDK uses an SDK key. Keys are specific to each project and environment. They are available on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Note>

  This code sample shows you how to pass custom parameters to the client by creating a custom configuration object.

  In this example, we've configured two properties for HTTP (the connect and socket timeouts), and one property for analytics events (the event flush interval).

  To pass custom parameters:

  <CodeGroup>
    ```java title="Java" lines wrap theme={null}
    LDConfig config = new LDConfig.Builder()
      .http(
        Components.httpConfiguration()
          .connectTimeout(Duration.ofSeconds(3))
          .socketTimeout(Duration.ofSeconds(3))
      )
      .events(
        Components.sendEvents()
          .flushInterval(Duration.ofSeconds(10))
      )
      .build();
    LDClient client = new LDClient("YOUR_SDK_KEY", config);
    ```
  </CodeGroup>

  To learn more about the specific configuration properties that are available in this SDK, read [`LDConfig.Builder`](https://launchdarkly.github.io/java-core/lib/sdk/server/com/launchdarkly/sdk/server/LDConfig.Builder.html).
</Accordion>

### Lua

<Accordion title="Expand Lua code sample">
  <Note>
    **The Lua SDK uses an SDK key**

    The Lua SDK uses an SDK key. Keys are specific to each project and environment. They are available on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Note>

  This code sample shows you how to pass custom parameters to the client by creating a custom configuration object.

  <Warning>
    **Finish setting up your configuration client before you call `LDClientInit`**

    You must finish setting up your configuration object before you call `clientInit`. If you initialize the client before configuration is complete, the SDK will not use anything you provide after initialization.
  </Warning>

  Here, we've configured the event queue capacity and flush interval parameters:

  <CodeGroup>
    ```lua title="Lua SDK v2" lines wrap theme={null}
    local config = {
        events = {
            capacity = 1000,
            flushIntervalMilliseconds  = 30000
        }
    }

    -- This blocks for 1 second to initialize
    local client = ld.clientInit("YOUR_SDK_KEY", 1000, config)
    ```
  </CodeGroup>

  To learn more about the specific configuration properties that are available in this SDK, read [`clientInit`](https://launchdarkly.github.io/lua-server-sdk/modules/launchdarkly-server-sdk.html#clientInit).
</Accordion>

### Node.js (server-side)

<Accordion title="Expand Node.js (server-side) code sample">
  <Note>
    **The Node.js (server-side) SDK uses an SDK key**

    The Node.js (server-side) SDK uses an SDK key. Keys are specific to each project and environment. They are available on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Note>

  This code sample shows you how to pass custom parameters to the client by creating a custom configuration object:

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

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

  To learn more about the specific configuration options available in this SDK, read [`LDOptions`](https://launchdarkly.github.io/js-core/packages/sdk/server-node/docs/interfaces/LDOptions.html).
</Accordion>

### PHP

<Accordion title="Expand PHP code sample">
  <Note>
    **The PHP SDK uses an SDK key**

    The PHP SDK uses an SDK key. Keys are specific to each project and environment. They are available on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Note>

  This code sample uses the `cache` option, which passes as an array to the client constructor. There are a few additional options you can set in this array.

  We've set the client connect timeout to three seconds in addition to providing a custom cache storage provider.

  <Warning>
    **Sending events in PHP**

    The LaunchDarkly SDK sends data back to our server to record events from track and variation calls. On our other platforms, this data is sent asynchronously, so that it adds no latency to serving web pages. PHP's shared-nothing architecture makes this difficult.

    By default, LaunchDarkly forks an external process that executes `curl` to send this data. In practice, we've found that this is the most reliable way to send data without introducing latency to page load times. If your server does not have `curl` installed, or has other restrictions that make it impossible to invoke `curl` as an external process, you may need to implement a custom `EventProcessor` to send events to LaunchDarkly.
  </Warning>

  Here is an example:

  <CodeGroup>
    ```php title="PHP" lines wrap theme={null}
    $client = new LaunchDarkly\LDClient("YOUR_SDK_KEY", ["cache" => $cacheStorage, "connect_timeout" => 3]);
    ```
  </CodeGroup>

  To learn more about the specific configuration options available in this SDK, read the SDK API documentation for the [`LDClient` constructor](http://launchdarkly.github.io/php-server-sdk/classes/LaunchDarkly-LDClient.html#method___construct).
</Accordion>

### Python

<Accordion title="Expand Python code sample">
  <Note>
    **The Python SDK uses an SDK key**

    The Python SDK uses an SDK key. Keys are specific to each project and environment. They are available on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Note>

  This code sample shows you how to pass custom parameters to the client by creating a custom configuration object:

  <CodeGroup>
    ```python title="Python" lines wrap theme={null}
    config = Config(sdk_key='YOUR_SDK_KEY', http=HTTPConfig(connect_timeout=5))
    ldclient.set_config(config)
    ```
  </CodeGroup>

  To learn more about the specific configuration options available in this SDK, read [`ldclient.config`](https://launchdarkly-python-sdk.readthedocs.io/en/latest/api-main.html#module-ldclient.config).
</Accordion>

### Ruby

<Accordion title="Expand Ruby code sample">
  <Note>
    **The Ruby SDK uses an SDK key**

    The Ruby SDK uses an SDK key. Keys are specific to each project and environment. They are available on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Note>

  This code sample shows you how to configure the behavior of the client by creating a custom configuration object.

  The client constructor takes a configuration object as an optional parameter. In this example, we've set the connection timeout to LaunchDarkly to one second, and the read timeout to two seconds.

  To create a custom configuration object:

  <CodeGroup>
    ```ruby title="Ruby" lines wrap theme={null}
    config = LaunchDarkly::Config.new({connect_timeout: 1, read_timeout: 2})
    client = LaunchDarkly::LDClient.new("YOUR_SDK_KEY", config)
    ```
  </CodeGroup>

  To learn more about the specific configuration options available in this SDK, read [`Config`](https://launchdarkly.github.io/ruby-server-sdk/LaunchDarkly/Config).
</Accordion>

### Rust

<Accordion title="Expand Rust code sample">
  <Note>
    **The Rust SDK uses an SDK key**

    The Rust SDK uses an SDK key. Keys are specific to each project and environment. They are available on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Note>

  This code sample shows you how to pass custom parameters to the client by creating a custom configuration object:

  <CodeGroup>
    ```rust title="Rust" lines wrap theme={null}
    let config = ConfigBuilder::new("YOUR_SDK_KEY")
      .offline(true)
      .build()
      .unwrap();
    let client = Client::build(config).unwrap();
    ```
  </CodeGroup>

  To learn more about the specific configuration options available in this SDK, read [`Config`](https://docs.rs/launchdarkly-server-sdk/latest/launchdarkly_server_sdk/struct.Config.html).
</Accordion>

## Edge SDKs

This feature is available in the following edge SDKs:

* [Akamai](#akamai)
* [Cloudflare](#cloudflare)
* [Fastly](#fastly)
* [Vercel](#vercel)

### Akamai

<Accordion title="Expand Akamai code sample">
  <Warning>
    **Akamai SDK credentials**

    The Akamai SDK requires a client-side ID. Client-side IDs are specific to each project and environment. They are not secret, and you can include them in edge code. Do not embed a server-side SDK key in an edge application.

    You can find client-side IDs on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Warning>

  This code sample shows you how to pass custom parameters to the client by creating a custom configuration object.

  <CodeGroup>
    ```ts title="Akamai SDK" lines wrap theme={null}
    import { init, LDOptions, BasicLogger } from '@launchdarkly/akamai-server-edgekv-sdk';

    const options: LDOptions = {
      logger: BasicLogger.get(),
      cacheTtlMs: 200,
    };

    const ldClient = init({
      sdkKey: 'example-client-side-id',
      namespace: 'your-edgekv-namespace',
      group: 'your-edgekv-group-id',
      options: options,
    });
    ```

    ```ts title="Akamai SDK, if using your own feature store" maxLines=0 expandable lines wrap theme={null}
    // If you are using your own feature store,
    // make sure to import 'init' from the 'akamai-server-base-sdk'
    // rather than from 'akamai-server-edgekv-sdk'

    import { init, EdgeProvider, LDOptions, BasicLogger } from '@launchdarkly/akamai-server-base-sdk';

    // When using your own feature store, you must create a new class that
    // implements EdgeProvider. To learn more, read
    // https://launchdarkly.com/docs/sdk/edge/akamai#getting-started
    class FeatureStore implements EdgeProvider {
      async get(rootKey: string): Promise<string> {
        return flagData;
      }
    }

    const options: LDOptions = {
      logger: BasicLogger.get(),
      cacheTtlMs: 200,
    };

    const ldClient = init({
      sdkKey: 'example-client-side-id',
      featureStoreProvider: new FeatureStore(),
      options: options,
    });
    ```
  </CodeGroup>

  To learn more about the specific configuration options available in this SDK, read [`LDOptions`](https://launchdarkly.github.io/js-core/packages/sdk/akamai-edgekv/docs/types/LDOptions.html). For additional discussion of the `cacheTtlMs` option, read [Understand resource limits and caching options](/docs/sdk/edge/akamai#understand-resource-limits-and-caching-options).
</Accordion>

### Cloudflare

<Accordion title="Expand Cloudflare code sample">
  <Warning>
    **Cloudflare SDK credentials**

    The Cloudflare SDK requires a client-side ID. Client-side IDs are specific to each project and environment. They are not secret, and you can include them in edge code. Do not embed a server-side SDK key in an edge application.

    You can find client-side IDs on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Warning>

  This code sample shows you how to pass custom parameters to the client by creating a custom configuration object.

  Versions 1 and 2 of the Cloudflare SDK only support the logger configuration option. Versions 2.3.0 and later also support an events configuration option.

  <CodeGroup>
    ```typescript title="Cloudflare SDK v2.3.0+ (TypeScript)" lines wrap theme={null}
    import { BasicLogger, init, LDOptions } from '@launchdarkly/cloudflare-server-sdk';

    const options: LDOptions = {
      logger: new BasicLogger({ destination: console.log }),
      sendEvents: true, // default is false
    };

    client = init('example-client-side-id', env.LD_KV, options);
    ```

    ```typescript title="Cloudflare SDK v2.2 and earlier (TypeScript)" lines wrap theme={null}
    import { BasicLogger, init, LDOptions } from '@launchdarkly/cloudflare-server-sdk';

    const options: LDOptions = {
      logger: new BasicLogger({ destination: console.log }),
    };

    client = init('example-client-side-id', env.LD_KV, options);
    ```
  </CodeGroup>

  To learn more about the specific configuration options available in this SDK, read the [SDK's API docs](https://launchdarkly.github.io/js-core/packages/sdk/cloudflare/docs/types/LDOptions.html).
</Accordion>

### Fastly

<Accordion title="Expand Fastly code sample">
  <Warning>
    **Fastly SDK credentials**

    The Fastly SDK requires a client-side ID. Client-side IDs are specific to each project and environment. They are not secret, and you can include them in edge code. Do not embed a server-side SDK key in an edge application.

    You can find client-side IDs on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Warning>

  This code sample shows you how to pass custom parameters to the client by creating a custom configuration object.

  <CodeGroup>
    ```ts title="TypeScript" expandable lines wrap theme={null}
    import { KVStore } from 'fastly:kv-store';
    import { init } from '@launchdarkly/fastly-server-sdk';

    const KV_STORE_NAME = 'launchdarkly';
    const EVENTS_BACKEND_NAME = 'launchdarkly';
    const store = new KVStore(KV_STORE_NAME);

    async function handleRequest(event: FetchEvent) {
      const ldClient = init('example-client-side-id', store, {
        eventsBackendName: EVENTS_BACKEND_NAME,
      });

      await ldClient.waitForInitialization();

      // ...
    }
    ```
  </CodeGroup>

  To learn more about the specific configuration options available in this SDK, read [`FastlySDKOptions`](https://launchdarkly.github.io/js-core/packages/sdk/fastly/docs/types/FastlySDKOptions.html).
</Accordion>

### Vercel

<Accordion title="Expand Vercel code sample">
  <Warning>
    **Vercel SDK credentials**

    The Vercel SDK requires a client-side ID. Client-side IDs are specific to each project and environment. They are not secret, and you can include them in edge code. Do not embed a server-side SDK key in an edge application.

    You can find client-side IDs on the **SDK keys** page under **Settings**. To learn more about key types, read [Keys](/docs/sdk/concepts/client-side-server-side#keys-and-credentials).
  </Warning>

  This code sample shows you how to pass custom parameters to the client by creating a custom configuration object.

  Version 1 of the Vercel SDK only supports the logger configuration option. Versions 1.2.0 and later also support an events configuration option.

  <CodeGroup>
    ```typescript title="Vercel SDK v1.2.0+" lines wrap theme={null}
    import { createClient } from '@vercel/edge-config';
    import { BasicLogger, init, LDOptions } from '@launchdarkly/vercel-server-sdk';

    const edgeConfigClient = createClient(process.env.EDGE_CONFIG);

    const options: LDOptions = {
      logger: new BasicLogger({ destination: console.log }),
      sendEvents: true, // default is false
    };

    client = init('example-client-side-id', edgeConfigClient, options);
    ```

    ```typescript title="Vercel SDK v1.0" lines wrap theme={null}
    import { createClient } from '@vercel/edge-config';
    import { BasicLogger, init, LDOptions } from '@launchdarkly/vercel-server-sdk';

    const edgeConfigClient = createClient(process.env.EDGE_CONFIG);

    const options: LDOptions = {
      logger: new BasicLogger({ destination: console.log }),
    };

    client = init('example-client-side-id', edgeConfigClient, options);
    ```
  </CodeGroup>

  To learn more about the specific configuration options available in this SDK, read [`LDOptions`](https://launchdarkly.github.io/js-core/packages/sdk/vercel/docs/types/LDOptions.html).
</Accordion>
