Built for Developers

Feature flags served in microseconds
and installed in minutes.

Setup

Java Feature Flags

Let's create a Java feature flag for a "One Click Checkout"

1.Add the LaunchDarkly SDK to your project

Check out our open source Java SDK on GitHub or read through the reference documentation.

               
       <dependency>
          <groupId>com.launchdarkly</groupId>
          <artifactId>launchdarkly-client</artifactId>
          <version> ... </version>
       </dependency>
                
              

2.Create a new LaunchDarkly client

               
       LDClient ldClient = new LDClient("YOUR_SDK_KEY");
                
              

3.Create a feature flag in LaunchDarkly

A flag allows you to manage a feature from the LaunchDarkly dashboard.

4.Wrap your code with a feature flag

First, create a user.  You can pass us any data about users for targeting and segmentation. 
Then, call BoolVariation and see whether the flag is on for that user.

               
       LDUser user = new LDUser(username);
       boolean showFeature = ldClient.BoolVariation("your.feature.key", user, false);
       if (showFeature) {
           // application code to show the feature
       }
           else {
           // the code to run if the feature is off
       }
                
              

5.Manage your flag

Use LaunchDarkly to determine which users see the feature.
You can roll out to a percentage of your users or target individual users/groups.

JavaScript Feature Flags

Let's create a JavaScript feature flag for a "One Click Checkout"

1.Add the SDK snippet to your site pages.

Check out the reference documentation.

               
       <head>
          <script src="https://app.launchdarkly.com/snippet/ldclient.min.js"></script>
       </head>
                
              

2.Set the user context for the page.

First, create a user.  You can pass us any data about users for targeting and segmentation.

               
            var user = {
              "key": "aa0ceb",
              "firstName": "Ernestina",
              "lastName": "Evans",
              "email": "ernestina@example.com",
              "custom": {
                "groups": ["Google", "Microsoft"]
              }
            };
            var ldclient = LDClient.initialize('YOUR_CLIENT_SIDE_ID_HERE', user);
                
              

3.Create a feature flag in LaunchDarkly

A flag allows you to manage a feature from the LaunchDarkly dashboard.

4.Wrap your code with a feature flag

Call variation and see whether the flag is on for that user.

               
            var showFeature = ldclient.variation("one_click_checkout", false);
            if (showFeature) {
              // Show "One Click Checkout" feature
            } else {
              // the code to run if the feature is off
            }
                
              

5.Manage your flag

Use LaunchDarkly to determine which users see the feature.

PHP Feature Flags

Let's create a PHP feature flag for a "One Click Checkout"

1.Install the SDK with Composer

Check out our open source PHP SDK on GitHub or read through the reference documentation.

               
       php composer.phar require launchdarkly/launchdarkly-php
                
              

2.Create a new LDClient with your SDK key.

               
       $client = new LaunchDarkly\LDClient("YOUR_SDK_KEY");
                
              

3.Create a feature flag in LaunchDarkly

A flag allows you to manage a feature from the LaunchDarkly dashboard.

4.Wrap your code in a feature flag.

First, create a user.  You can pass us any data about users for targeting and segmentation. 
Then, call variation and see whether the flag is on for that user.

               
       $builder = (new LaunchDarkly\LDUserBuilder("bob@example.com"))
          ->firstName("Bob")
          ->lastName("Loblaw")
          ->custom(["groups" => "beta_testers"]);

       $user = $builder->build();

       if ($client->variation("one_click_checkout", $user)) {
       // application code to show the feature
       } else {
       // the code to run if the feature is off
       }
                
              

5.Manage your flag

Use LaunchDarkly to determine which users see the feature.
You can roll out to a percentage of your users or target individual users/groups.

Python Feature Flags

Let's create a Python feature flag for a "One Click Checkout"

1.Install the SDK with pip

Check out our open source Python SDK on GitHub or read through the reference documentation.

               
       pip install ldclient-py
                
              

2.Create a new LaunchDarkly client

               
       ld_client = LDClient("YOUR_SDK_KEY")
                
              

3.Create a feature flag in LaunchDarkly

A flag allows you to manage a feature from the LaunchDarkly dashboard.

4.Wrap your code with a feature flag

First, create a user.  You can pass us any data about users for targeting and segmentation. 
Then, call variation and see whether the flag is on for that user.

               
        user = {
          "key": "bob@example.com",
          "firstName": "Bob",
          "lastName": "Loblaw",
          "custom": {
            "groups": "beta_testers"
          }
        }

        show_feature = ld_client.variation("one_click_checkout", user, False)

        if show_feature:
          # Showing One Click Checkout
        else:
          # Not Showing One Click Checkout

                
              

5.Manage your flag

Use LaunchDarkly to determine which users see the feature.
You can roll out to a percentage of your users or target individual users/groups.

Go Feature Flags

Let's create a Go feature flag for a "One Click Checkout"

1.Install the SDK with the go tool

Check out our open source Go SDK on GitHub or read through the reference documentation.

               
       go get github.com/launchdarkly/go-client
                
              

2.Create a new LaunchDarkly client

               
       ld_client := ld.MakeClient("YOUR_SDK_KEY", 5 * time.Second)
                
              

3.Create a feature flag in LaunchDarkly

A flag allows you to manage a feature from the LaunchDarkly dashboard.

4.Wrap your code with a feature flag

First, create a user.  You can pass us any data about users for targeting and segmentation. 
Then, call BoolVariation and see whether the flag is on for that user.

               
        key := "bob@example.com"
        first := "Bob"
        last := "Loblaw"
        custom := map[string]interface{}{"groups": "beta_testers"}

        user := ld.User{
          Key: &key,
          FirstName: &first,
          LastName:  &last,
          Custom:    &custom,
        }

        show_feature, _ := client.BoolVariation("one_click_checkout", user, false)

        if show_feature {
          // Showing One Click Checkout
          fmt.Println("Showing your feature to " + *user.Key)
        } else {
          // Not Showing One Click Checkout
          fmt.Println("Not showing your feature to " + *user.Key)
        }
                
              

5.Manage your flag

Use LaunchDarkly to determine which users see the feature.
You can roll out to a percentage of your users or target individual users/groups.

Ruby Feature Flags

Let's create a Ruby feature flag for a "One Click Checkout"

1.Install the SDK with gem

Check out our open source Ruby SDK on GitHub or read through the reference documentation.

               
       gem install ldclient-rb
                
              

2.Create a new LaunchDarkly client

               
       ld_client = LaunchDarkly::LDClient.new("YOUR_SDK_KEY")
                
              

3.Create a feature flag in LaunchDarkly

A flag allows you to manage a feature from the LaunchDarkly dashboard.

4.Wrap your code with a feature flag

First, create a user.  You can pass us any data about users for targeting and segmentation. 
Then, call variation and see whether the flag is on for that user.

               
        user = {
          key: "bob@example.com",
          firstName: "Bob",
          lastName: "Loblaw",
          custom: {
            groups: "beta_testers"
          }
        }

        if ld_client.variation("one_click_checkout", user, false)
          # showing one click checkout
          puts "Showing your feature to #{user[:key]}"
        else
          # the code to run if the feature is off
          puts "Not showing your feature to #{user[:key]}"
        end
                
              

5.Manage your flag

Use LaunchDarkly to determine which users see the feature.
You can roll out to a percentage of your users or target individual users/groups.

Node.js Feature Flags

Let's create a Node feature flag for a "One Click Checkout"

1.Install the SDK with npm

Check out our open source Node SDK on GitHub or read through the reference documentation.

               
       npm install ldclient-node --save
                
              

2.Create a new LaunchDarkly client

               
       ldclient = LaunchDarkly.init("YOUR_SDK_KEY"))
                
              

3.Create a feature flag in LaunchDarkly

A flag allows you to manage a feature from the LaunchDarkly dashboard.

4.Wrap your code with a feature flag

First, create a user.  You can pass us any data about users for targeting and segmentation. 
Then, call variation and see whether the flag is on for that user.

               
        var user = {
          "firstName": "Bob",
          "lastName": "Loblaw",
          "key": "bob@example.com",
          "custom": {
            "groups": "beta_testers"
          }
        };

        ldclient.variation("one_click_checkout", user, false, function(err, showFeature) {
          if (showFeature) {
            // application code to show One Click Checkout
            console.log("Showing your feature to " + user.key );
          } else {
            // the code to run if the feature is off
            console.log("Not showing your feature to " + user.key);
          }
        });
                
              

5.Manage your flag

Use LaunchDarkly to determine which users see the feature.
You can roll out to a percentage of your users or target individual users/groups.

.NET Feature Flags

Let's create a .NET feature flag for a "One Click Checkout"

1.Use NuGet to add the SDK to your project

Check out our open source .NET SDK on GitHub or read through the reference documentation.

               
       Install-Package LaunchDarkly.Client
                
              

2.Create a new LaunchDarkly client

               
       LdClient client = new LdClient("YOUR_SDK_KEY");
                
              

3.Create a feature flag in LaunchDarkly

A flag allows you to manage a feature from the LaunchDarkly dashboard.

4.Wrap your code with a feature flag

First, create a user.  You can pass us any data about users for targeting and segmentation. 
Then, call variation and see whether the flag is on for that user.

               
        User user = User.WithKey("bob@example.com")
          .AndFirstName("Bob")
          .AndLastName("Loblaw")
          .AndCustomAttribute("groups", "beta_testers");
        bool showFeature = await client.variation("one_click_checkout", user, false);
        if (showFeature) {
          // Show One Click Checkout
        }
        else {
          // the code to run if the feature is off
        }
                
              

5.Manage your flag

Use LaunchDarkly to determine which users see the feature.
You can roll out to a percentage of your users or target individual users/groups.

Python Twisted Feature Flags

Let's create a Python Twisted feature flag for a "One Click Checkout"

1.Install the SDK with pip

Check out our open source Python SDK on GitHub or read through the reference documentation.

               
       pip install ldclient-py[twisted]
                
              

2.Create a new LaunchDarkly client

               
       ld_client = TwistedLDClient("YOUR_SDK_KEY")
                
              

3.Create a feature flag in LaunchDarkly

A flag allows you to manage a feature from the LaunchDarkly dashboard.

4.Wrap your code with a feature flag

First, create a user.  You can pass us any data about users for targeting and segmentation. 
Then, call variation and see whether the flag is on for that user.

               
        show_feature = yield ld_client.variation("one_click_checkout", {"key": "user@test.com"}, False)
        if show_feature:
            # application code to show One Click Checkout
        else:
            # the code to run if the feature is off
                
              

5.Manage your flag

Use LaunchDarkly to determine which users see the feature.
You can roll out to a percentage of your users or target individual users/groups.

Mobile iOS Feature Flags

Let's create a mobile iOS feature flag for a "One Click Checkout"

1.Use CocoaPods to install the LaunchDarkly SDK:

Check out our open source mobile iOS SDK on GitHub or read through the reference documentation.

               
       target 'hello-ios' do
         pod 'LaunchDarkly'
       end
                
              

2.Import the LaunchDarkly library

               
         #import "LDClient.h"
                
              

3.Add a user property

               
          @interface ViewController ()
          @property LDUserModel *user;
          @end

          @implementation ViewController
          @synthesize user;
                
              

4.Create a new user

You can pass us any data about users for targeting and segmentation.

               
          LDUserBuilder *builder = [[LDUserBuilder alloc] init];
          builder = [builder withKey:@"bob@example.com"];
          builder = [builder withFirstName:@"Bob"];
          builder = [builder withLastName:@"Loblaw"];

          user = [builder build];

          NSArray *groups = @[@"beta_testers"];
          builder = [builder withCustomArray:@"groups" value:groups];
                
              

5.Create a feature flag in LaunchDarkly

A flag allows you to manage a feature from the LaunchDarkly dashboard.

6.Wrap your code with a feature flag

Create a new LDClient and call 'boolVariation' to check the flag value for the user.

               
            LDConfigBuilder *config = [[LDConfigBuilder alloc] init];
            [config withMobileKey:@"mob-9925194d-c7f1-4266-946f-805f3cc29656"];

            [[LDClient sharedInstance] start:config userBuilder:builder];

          -(void) checkFeatureValue {
            BOOL showFeature = [[LDClient sharedInstance] boolVariation:@"one_click_checkout" default:NO];

            if (showFeature) {
              NSLog(@"showing One Click Checkout feature for %@", user.key);
            } else {
              NSLog(@"not showing One Click Checkout for %@", user.key);
            }
          }
                
              

7.Manage your flag

Use LaunchDarkly to determine which users see the feature.
You can roll out to a percentage of your users or target individual users/groups.

Mobile Android Feature Flags

Let's create a mobile Android feature flag for a "One Click Checkout"

1.In your build.gradle file, declare a dependency on the LaunchDarkly Android SDK:

Check out our open source mobile Android SDK on GitHub or read through the reference documentation.

               
       compile 'com.launchdarkly:launchdarkly-android-client:#.#.#'
                
              

2.Use the builder pattern to construct a user object:

You can pass us any data about users for targeting and segmentation.

               
          user = new LDUser.Builder("aa0ceb")
           .email("fake@example.com")
           .firstName("Jake")
           .lastName("Fake")
           .custom("group", "microsoft")
           .build();
                
              

3.Create a config object, then initialize the shared instance of LDClient

               
          LDConfig ldConfig = new LDConfig.Builder()
              .setMobileKey("YOUR_MOBILE_KEY")
              .build();

          LDClient ldClient = LDClient.init(this.getApplication(), ldConfig, user, 5);
                
              

4.Create a feature flag in LaunchDarkly

A flag allows you to manage a feature from the LaunchDarkly dashboard.

5.Wrap your code with a feature flag

Call BoolVariation to check the flag value for the user.

               
                  LDClient.get().BoolVariation("your.feature.key", user, false);
                      if (showFeature) {
                          // application code to show the feature
                      }
                      else {
                          // the code to run if the feature is off
                      }
                
              

6.Manage your flag

Use LaunchDarkly to determine which users see the feature.
You can roll out to a percentage of your users or target individual users/groups.

Powerful REST API
Build custom integrations or export your data.
API Documentation