Welcome to LaunchDarkly
This topic walks you through creating a LaunchDarkly account, installing an SDK, and creating and targeting your first feature flag. Along the way, you’ll learn why feature flags are useful. In this guide, you will:- Sign up for a free LaunchDarkly trial
- Install a LaunchDarkly SDK
- Create your first feature flag
- Retrieve the value of the feature flag from your code
- Create and target an audience with the feature flag

An illustration describing a feature flag.
What is a feature flag?
What is a feature flag?
How feature flags work
How feature flags work

How a client-side SDK retrieves a feature flag value from LaunchDarkly.
variation().Why are feature flags useful?
Why are feature flags useful?
1. Sign up for a free trial
First, let’s create your LaunchDarkly account and start a free trial. Your free trial gives you 14 days to try all LaunchDarkly tools, including the core unit of work in LaunchDarkly: feature flags. After 14 days have elapsed, your trial automatically converts to a developer tier plan. This plan tier is free up to 1,000 users or contexts per month and 10,000 experiment keys. Sign up for a free trial. Here is what a typical Flags list in LaunchDarkly looks like:
The Flags list in LaunchDarkly.
2. Install an SDK for your codebase
Next, let’s install a LaunchDarkly SDK in the language or framework that you use today. Open your command line interface (CLI) and use your package manager of choice to install a LaunchDarkly SDK. The SDK helps you retrieve your first feature flag quickly and easily. To install, select your package manager and copy and paste the command into your CLI:3. Create your first feature flag
Awesome! You’re ready to create your first feature flag. In this section, you will:- Create a feature flag.
- Build your first context.
- Retrieve the value of the feature flag.
- Integrate the feature flag into the demo code.
- Navigate to the Flags list in the LaunchDarkly UI. The Flags list is empty because this LaunchDarkly project doesn’t have any feature flags yet.
- Click Create flag. The “Create flag” dialog opens.
- Give the flag a name and write a description explaining what it does. The flag key automatically populates based on the name you enter.
- Click Create flag.

The toggle button to turn on the feature flag.
4. Retrieve the value of your first feature flag

An illustration of retrieving a feature flag.
Initialize your LaunchDarkly client
Return to the software project where you installed the LaunchDarkly SDK. Now you can configure the LaunchDarkly client to your account. After you have authenticated, you can retrieve the feature flag you created in Step 3: Create your first feature flag. Different credentials are available in LaunchDarkly. Here are their names and how they are used:- Environment key: A unique string that identifies each environment in your project. By default, your account is configured with “Production” and “Test” environments. This key is not used in the LaunchDarkly SDKs.
- SDK key: This string authorizes a LaunchDarkly client to connect from your server. It is a secret that you should import into your code securely. A common way of doing this is by importing it into your code as an environment variable.
- Mobile key: This string authorizes a LaunchDarkly client in a mobile SDK, like iOS or Android. Mobile keys can be reset, so they do not need to be kept secret.
- Client-side ID: This string authorizes a LaunchDarkly client for client-side and edge SDKs. The client-side ID does not need to be kept secret. Unlike the mobile key, it cannot be reset.
Expand Implementing LaunchDarkly with an SDK key
Expand Implementing LaunchDarkly with an SDK key

The "Environments" page in LaunchDarkly with the overflow menu for an environment displayed.
Expand Implementing LaunchDarkly with a client-side ID
Expand Implementing LaunchDarkly with a client-side ID

The "Environments" page in LaunchDarkly with the overflow menu for an environment displayed.
Expand Implementing LaunchDarkly with a mobile key
Expand Implementing LaunchDarkly with a mobile key

The "Environments" page in LaunchDarkly with the overflow menu for an environment displayed.
Config with the SDK key, client-side ID, or mobile key passed as a string:
SDK successfully initialized!
Great! Now you can build your first context.
Build your first context
When you use the LaunchDarkly client to retrieve a feature flag, you need to pass LaunchDarkly a context that describes the audience encountering the feature flag. A context can include any attribute of an audience that your app has captured: email address, user type, company or organization, device type, screen size, demography, geography, or any other descriptor you can define. If you need to, you can pass more than one context to LaunchDarkly simultaneously when retrieving a feature flag. For the purposes of this example, start by defining a context as a user. Using the code samples below, expand the test code from earlier in this tutorial by creating the first context with a demo user named “Sandy.” The code samples define the user’skind, name, email address, and a demo user ID string.
context, you can get the value of your first feature flag.
Retrieving your first feature flag
Now you can retrieve the value of the feature flag. To write this code, return to the feature flag you created earlier and copy the feature flag’s key to your clipboard.
The menu for your first feature flag illustrating the location of the feature flag key.
false:
Our first feature flag is: true
The flag you turned on in Step 3 returns true.
Next, let’s explore how you can use a feature flag’s value in more realistic code.
Returning to the Flags list in the LaunchDarkly UI, find the feature flag you created, click Off underneath “Targeting configuration for Test” and then click Review and save.

The menu for the feature flag, with the toggle to turn the flag off called out.
Our first feature flag is: false
The flag you just turned off now has a value of false.
Integrate your first feature flag
The demo code you created earlier is intended to introduce you to the three important concepts of LaunchDarkly: feature flags, authenticated clients, and contexts. Now we can explore how you can integrate them in a more realistic software project. Imagine that you have a new template you wish to deploy. Using a feature flag will let you deploy this template to a small subset of users first before rolling it out progressively to the entire user base. Explore this pseudocode that describes how such an implementation could look in production:5. Targeting the audience for your first feature flag
Great! You’re ready to target an audience. In this step, you will:- Create your first audience.
- Add your first targeting rule.
- Confirm your targeting rule works.
Create your first audience
Here is some code to create some more demonstration users you can target with the feature flag. This code creates three new users: Alice, Bob, and Carlos. Alice and Bob use the context kinduser, the same as Sandy. Carlos uses the context kind beta-user. You will configure your targeting so that contexts with the kind user receive false, while Carlos, the beta-user, continues to receive true.
false from the feature flag.
- Alice’s flag value is:
false - Bob’s flag value is:
false - Carlos’ flag value is:
false
user receive false and Carlos, the beta-user, remains true.
Add your first targeting rule
Return to the feature flag in the LaunchDarkly UI, then set the feature flag to only target contexts with thekind “beta-user.”
First, click the View targeting rules to display the flag’s existing default rule:

The "View targeting rules" option on a feature flag.

The dropdown menu to add a custom rule to a feature flag.
false to all contexts with kind user. Describe the rule by typing an explanation in the Description field. In the attribute list, choose Context kind. In Values, enter user:

The menu to target a specific context kind called 'user'.

The dropdown menu to set the feature flag's return for the targeted audience to false.

The toggle to turn on the feature flag for the beta users.
false to all contexts with the user kind. Because Carlos is a beta-user, he does not match the rule and continues to receive true.
Return to your demo code to see this in action.
Confirm your targeting rule
Return to the code and execute it again. Alice and Bob now receivefalse, while Carlos, the context with the beta-user kind, continues to receive true:
- Alice’s flag value is:
false - Bob’s flag value is:
false - Carlos’ flag value is:
true
Context and building targeting rules in your feature flags, your new features can target the precise audience you intend.
And with that, you’re done!
6. What’s next
Let’s review what you accomplished: With some demonstration code, you installed a LaunchDarkly SDK, created a feature flag, retrieved the value of the flag, explored integrating the feature flag in production, and targeted your first audience of users with your first feature flag. Congratulations on taking the first steps toward a safer, faster, and more effective methodology for deploying new code with LaunchDarkly. This is only the beginning.
An illustration of feature flags, experiments, and progressive and guarded rollouts.
- Learn more about contexts to describe your users and target them with rules
- Learn to create your first experiment to A/B test new features
- Manage your deployment with a release
- Create your first custom metric to measure the effectiveness of your new features
- Debug your integration with your SDK’s API reference
- Take a course in LaunchDarkly Academy
- Set up your SDK to integrate LaunchDarkly into your application
- Connect an AI assistant to manage flags with natural language via the LaunchDarkly MCP server
- Get started with AgentControl to manage AI agent configs without redeploying