Learn how to set up LaunchDarkly, including experimentation alongside Flags SDK and Edge Config.
This example uses LaunchDarkly for feature flags with the Flags SDK along with the @flags-sdk/launchdarkly
LaunchDarkly adapter and the Flags Explorer.
https://flags-sdk-launchdarkly.vercel.app/
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.
The easiest way to get started with LaunchDarkly is through the integration in Vercel Marketplace.
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.
This allows the Flags SDK and the Flags Explorer to work correctly, by getting additional metadata.
vercel env pull
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:
Control
, Value: blue
Test
, Value: green
Test #2
, Value: red
You can also find the flag keys in the flags.ts
file.
Ensure all Flags are ON.
Create the Proceed to Checkout
experiment:
Proceed to Checkout
Button color influences rate at which customers proceed to checkout
Feature change
user
key
Custom
proceed-to-checkout-clicked
Occurence (conversion: binary)
Percentage of user units that sent the event, where higher is better
Proceed to Checkout Clicked
proceed-to-checkout
Custom
and enter 100
%Split equally
After that, start the Experiment.
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.
Learn how to set up LaunchDarkly, including experimentation alongside Flags SDK and Edge Config.
This example uses LaunchDarkly for feature flags with the Flags SDK along with the @flags-sdk/launchdarkly
LaunchDarkly adapter and the Flags Explorer.
https://flags-sdk-launchdarkly.vercel.app/
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.
The easiest way to get started with LaunchDarkly is through the integration in Vercel Marketplace.
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.
This allows the Flags SDK and the Flags Explorer to work correctly, by getting additional metadata.
vercel env pull
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:
Control
, Value: blue
Test
, Value: green
Test #2
, Value: red
You can also find the flag keys in the flags.ts
file.
Ensure all Flags are ON.
Create the Proceed to Checkout
experiment:
Proceed to Checkout
Button color influences rate at which customers proceed to checkout
Feature change
user
key
Custom
proceed-to-checkout-clicked
Occurence (conversion: binary)
Percentage of user units that sent the event, where higher is better
Proceed to Checkout Clicked
proceed-to-checkout
Custom
and enter 100
%Split equally
After that, start the Experiment.
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.