VercelLogotypeVercelLogotype
LoginSign Up
Back to Templates

LaunchDarkly Flags SDK Example

Learn how to set up LaunchDarkly, including experimentation alongside Flags SDK and Edge Config.

DeployView Demo
Flags + LaunchDarkly light

LaunchDarkly Flags SDK Example

This example uses LaunchDarkly for feature flags with the Flags SDK along with the @flags-sdk/launchdarkly LaunchDarkly adapter and the Flags Explorer.

How it works

This demo uses two feature flags on LaunchDarkly to control the visibility of two banners on the page. Both flags are configured to show/hide each banner 50% of the time.

Once you visit the page, you can see a variation of both/one/none of the banners. Since this example is using a stable id to identify users, you will see the same variation until you reset your id.

To test different variations, you can use the Dev Tools at the bottom to reset the stable id and reload the page. This allows you to test different variations of the banners.

If you deployed your own and configured the feature flags on LaunchDarkly, you can also use the Flags Explorer to test different variations by creating overrides.

Deploy this template

The easiest way to get started with LaunchDarkly is through the integration in Vercel Marketplace.

Step 1: Link the project

In order to use the Flags Explorer, you need to link the project on your local machine.

vercel link

Select the project from the list you just deployed.

Step 2: Pull all environment variables

This allows the Flags SDK and the Flags Explorer to work correctly, by getting additional metadata.

vercel env pull

Step 3: Create Feature Flags

Head over to the LaunchDarkly Console and create the feature flags and experiments required by this template.

Be sure to enable the SDKs using Client-side ID option for each Feature Flag.

Feature Flags:

  • Summer Sale (type boolean) with the key summer-sale and the variations true and false. Edit the default targeting rule to serve a percentage rollout with a 50/50 split by user.key.
  • Free Delivery (type boolean) with the key free-delivery and the variations true and false. Edit the default targeting rule to serve a percentage rollout with a 50/50 split by user.key.
  • Proceed to Checkout (type string) with the key proceed-to-checkout and the following variations:
    • Name: Control, Value: blue
    • Name: Test, Value: green
    • Name: Test #2, Value: red

You can also find the flag keys in the flags.ts file.

Ensure all Flags are ON.

Step 4: Configure the Experiment

Create the Proceed to Checkout experiment:

  • Name: Proceed to Checkout
  • Hypothesis: Button color influences rate at which customers proceed to checkout
  • Type: Feature change
  • Randomization Unit: user
  • Randomization Attribute: key
  • Metric: Create a new metric:
    • Event kind: Custom
    • Event key: proceed-to-checkout-clicked
    • What do you want to measure? Occurence (conversion: binary)
    • Metric definition: Percentage of user units that sent the event, where higher is better
    • Metric name: Proceed to Checkout Clicked
  • Varaiations: Choose flag proceed-to-checkout
  • Audience:
    • In this experiment: Choose Custom and enter 100%
    • Split audience: Choose Split equally
  • Statistical approach: Default values

After that, start the Experiment.

Step 6: Set environment variables

See .env.example for a template.

  • FLAGS_SECRET
  • EDGE_CONFIG (Vercel Edge Config connection string)
  • LAUNCHDARKLY_PROJECT_SLUG
  • LAUNCHDARKLY_CLIENT_SIDE_ID
  • NEXT_PUBLIC_LAUNCHDARKLY_CLIENT_SIDE_ID (set to same value as LAUNCHDARKLY_CLIENT_SIDE_ID)

(Optional) If you provide the LAUNCHDARKLY_API_KEY, LAUNCHDARKLY_PROJECT_KEY and LAUNCHDARKLY_ENVIRONMENT environment variables, the Flags Explorer will fetch additional metadata from the LaunchDarkly API.

This will show the description (if set) and displays a link to the feature flag on the LaunchDarkly Console.

You can create an API key and find project and environment values in the LaunchDarkly Console.

GitHub Repovercel/examples
Use Cases
Edge ConfigEdge Middleware
Stack
Next.jsTailwind
Experimentation
LaunchDarkly

Related Templates

Get Started

  • Templates
  • Supported frameworks
  • Marketplace
  • Domains

Build

  • Next.js on Vercel
  • Turborepo
  • v0

Scale

  • Content delivery network
  • Fluid compute
  • CI/CD
  • Observability
  • AI GatewayNew
  • Vercel AgentNew

Secure

  • Platform security
  • Web Application Firewall
  • Bot management
  • BotID
  • SandboxNew

Resources

  • Pricing
  • Customers
  • Enterprise
  • Articles
  • Startups
  • Solution partners

Learn

  • Docs
  • Blog
  • Changelog
  • Knowledge Base
  • Academy
  • Community

Frameworks

  • Next.js
  • Nuxt
  • Svelte
  • Nitro
  • Turbo

SDKs

  • AI SDK
  • Workflow SDKNew
  • Flags SDK
  • Chat SDK
  • Streamdown AINew

Use Cases

  • Composable commerce
  • Multi-tenant platforms
  • Web apps
  • Marketing sites
  • Platform engineers
  • Design engineers

Company

  • About
  • Careers
  • Help
  • Press
  • Legal
  • Privacy Policy

Community

  • Open source program
  • Events
  • Shipped on Vercel
  • GitHub
  • LinkedIn
  • X
  • YouTube

Loading status…

Select a display theme:
    • AI Cloud
      • v0

        Build applications with AI

      • AI SDK

        The AI Toolkit for TypeScript

      • AI Gateway

        One endpoint, all your models

      • Vercel Agent

        An agent that knows your stack

      • Sandbox

        AI workflows in live environments

    • Core Platform
      • CI/CD

        Helping teams ship 6× faster

      • Content Delivery

        Fast, scalable, and reliable

      • Fluid Compute

        Servers, in serverless form

      • Observability

        Trace every step

    • Security
      • Bot Management

        Scalable bot protection

      • BotID

        Invisible CAPTCHA

      • Platform Security

        DDoS Protection, Firewall

      • Web Application Firewall

        Granular, custom protection

    • Company
      • Customers

        Trusted by the best teams

      • Blog

        The latest posts and changes

      • Changelog

        See what shipped

      • Press

        Read the latest news

      • Events

        Join us at an event

    • Learn
      • Docs

        Vercel documentation

      • Academy

        Linear courses to level up

      • Knowledge Base

        Find help quickly

      • Community

        Join the conversation

    • Open Source
      • Next.js

        The native Next.js platform

      • Nuxt

        The progressive web framework

      • Svelte

        The web’s efficient UI framework

      • Turborepo

        Speed with Enterprise scale

    • Use Cases
      • AI Apps

        Deploy at the speed of AI

      • Composable Commerce

        Power storefronts that convert

      • Marketing Sites

        Launch campaigns fast

      • Multi-tenant Platforms

        Scale apps with one codebase

      • Web Apps

        Ship features, not infrastructure

    • Tools
      • Marketplace

        Extend and automate workflows

      • Templates

        Jumpstart app development

      • Partner Finder

        Get help from solution partners

    • Users
      • Platform Engineers

        Automate away repetition

      • Design Engineers

        Deploy for every idea

  • Enterprise
  • Pricing
Log InContact
Sign Up
Sign Up
Back to Templates
DeployView Demo

Flags SDK with Hypertune and Next.js

An e-commerce example built with Hypertune and Flags SDK that works well with Vercel Marketplace
Flags SDK with Hypertune and Next.js

Statsig Experimentation with Flags SDK

Run experiments on static pages with Statsig and the Flags SDK
Statsig Experimentation with Flags SDK
v0

Build applications with AI

AI SDK

The AI Toolkit for TypeScript

AI Gateway

One endpoint, all your models

Vercel Agent

An agent that knows your stack

Sandbox

AI workflows in live environments

CI/CD

Helping teams ship 6× faster

Content Delivery

Fast, scalable, and reliable

Fluid Compute

Servers, in serverless form

Observability

Trace every step

Bot Management

Scalable bot protection

BotID

Invisible CAPTCHA

Platform Security

DDoS Protection, Firewall

Web Application Firewall

Granular, custom protection

Customers

Trusted by the best teams

Blog

The latest posts and changes

Changelog

See what shipped

Press

Read the latest news

Events

Join us at an event

Docs

Vercel documentation

Academy

Linear courses to level up

Knowledge Base

Find help quickly

Community

Join the conversation

Next.js

The native Next.js platform

Nuxt

The progressive web framework

Svelte

The web’s efficient UI framework

Turborepo

Speed with Enterprise scale

AI Apps

Deploy at the speed of AI

Composable Commerce

Power storefronts that convert

Marketing Sites

Launch campaigns fast

Multi-tenant Platforms

Scale apps with one codebase

Web Apps

Ship features, not infrastructure

Marketplace

Extend and automate workflows

Templates

Jumpstart app development

Partner Finder

Get help from solution partners

Platform Engineers

Automate away repetition

Design Engineers

Deploy for every idea