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// Set your LaunchDarkly SDK key.
7// This is inlined as example only for onboarding.
8// Never hardcode your SDK key in production.
9var ldConfig = Configuration.Default("YOUR_SDK_KEY");
10var client = new LdClient(ldConfig);
11
12if (client.Initialized)
13{
14 // For onboarding purposes only we flush events as soon as
15 // possible so we quickly detect your connection.
16 // You don't have to do this in practice because events are automatically flushed.
17 client.Flush();
18 Console.WriteLine("*** SDK successfully initialized!\n");
19}
20else
21{
22 Console.WriteLine("*** SDK failed to initialize\n");
23 Environment.Exit(1);
24}

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.