Set up .NET (server-side) SDK

Install the package

C#
$Install-Package LaunchDarkly.ServerSdk

Initialize the SDK

.NET (server-side) SDK initialization
1using LaunchDarkly.Sdk;
2using LaunchDarkly.Sdk.Server;
3
4var builder = WebApplication.CreateBuilder(args);
5
6// This is your LaunchDarkly SDK key.
7// Never hardcode your SDK key in production.
8var ldConfig = Configuration.Default("YOUR_SDK_KEY");
9var client = new LdClient(ldConfig);
10
11if (client.Initialized)
12{
13 // For onboarding purposes only we flush events as soon as
14 // possible so we quickly detect your connection.
15 // You don't have to do this in practice because events are automatically flushed.
16 client.Flush();
17 Console.WriteLine("*** SDK successfully initialized!\n");
18}
19else
20{
21 Console.WriteLine("*** SDK failed to initialize\n");
22 Environment.Exit(1);
23}

You can find your server-side SDK key, client-side ID, and mobile key in the “Resources” section of the help menu. Click the help icon at the bottom left corner of the LaunchDarkly UI, then choose SDK keys:

The SDK keys option in the help menu.

The SDK keys option in the help menu.

To learn more, read Initialize the client in the .NET (server-side) SDK reference guide.