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. Details about each SDK’s configuration are available in the SDK-specific sections below:Client-side SDKs
This feature is available in the following client-side SDKs:- .NET (client-side)
- Android
- C++ (client-side)
- Electron
- Flutter
- iOS
- JavaScript
- Node.js (client-side)
- React Native
- Roku
- Vue
.NET (client-side)
Expand .NET (client-side) code sample
Expand .NET (client-side) code sample
Configuration.Builder:Configuration.Android
Expand Android code sample
Expand Android code sample
LDConfig.Builder.C++ (client-side)
Expand C++ (client-side) code sample
Expand C++ (client-side) code sample
ConfigBuilder. To learn more about the event queue capacity and flush interval parameters specifically, read EventsBuilder.Electron
Expand Electron code sample
Expand Electron code sample
LDOptions.Flutter
Expand Flutter code sample
Expand Flutter code sample
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:LDConfig.iOS
Expand iOS code sample
Expand iOS code sample
LDConfig.JavaScript
Expand JavaScript code sample
Expand JavaScript code sample
LDOptions.Node.js (client-side)
Expand Node.js (client-side) code sample
Expand Node.js (client-side) code sample
LDOptions.React Native
Expand React Native code sample
Expand React Native code sample
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.Here is an example:LDOptions.Roku
Expand Roku code sample
Expand Roku code sample
Vue
Expand Vue code sample
Expand Vue code sample
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.Here is an example of each:Server-side SDKs
This feature is available for the following server-side SDKs:- .NET (server-side)
- Apex
- C++ (server-side)
- Erlang
- Go
- Haskell
- Java
- Lua
- Node.js (server-side)
- PHP
- Python
- Ruby
- Rust
.NET (server-side)
Expand .NET (server-side) code sample
Expand .NET (server-side) code sample
ConfigurationBuilder.Apex
Expand Apex code sample
Expand Apex code sample
LDConfig.Builder.C++ (server-side)
Expand C++ (server-side) code sample
Expand C++ (server-side) code sample
ConfigBuilder. To learn more about the event queue capacity and flush interval parameters specifically, read EventsBuilder.Erlang
Expand Erlang code sample
Expand Erlang code sample
Options map parameter. The code in this example turns off streaming, so the SDK connects to LaunchDarkly through polling.To pass custom parameters:ldclient_config.Go
Expand Go code sample
Expand Go code sample
Config.Haskell
Expand Haskell code sample
Expand Haskell code sample
Config.Java
Expand Java code sample
Expand Java code sample
LDConfig.Builder.Lua
Expand Lua code sample
Expand Lua code sample
clientInit.Node.js (server-side)
Expand Node.js (server-side) code sample
Expand Node.js (server-side) code sample
LDOptions.PHP
Expand PHP code sample
Expand PHP code sample
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.Here is an example:LDClient constructor.Python
Expand Python code sample
Expand Python code sample
ldclient.config.Ruby
Expand Ruby code sample
Expand Ruby code sample
Config.Rust
Expand Rust code sample
Expand Rust code sample
Config.Edge SDKs
This feature is available in the following edge SDKs:Akamai
Expand Akamai code sample
Expand Akamai code sample
LDOptions. For additional discussion of the cacheTtlMs option, read Understand resource limits and caching options.Cloudflare
Expand Cloudflare code sample
Expand Cloudflare code sample
Fastly
Expand Fastly code sample
Expand Fastly code sample
FastlySDKOptions.Vercel
Expand Vercel code sample
Expand Vercel code sample
LDOptions.