Documentation Index
Fetch the complete documentation index at: https://launchdarkly-preview.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This topic documents how to get started with the Vercel SDK, and links to reference information on all of the supported features.LaunchDarkly’s SDKs are open source. In addition to this reference guide, we provide source, API reference documentation, and a sample application:
| Resource | Location |
|---|---|
| SDK API documentation | SDK API docs |
| Supported SDK Versions | Vercel edge SDK |
| GitHub repository | LaunchDarkly Vercel SDK |
- The Vercel SDK gets all flags at the edge for a given context, and bootstraps them onto a cached payload
- The client-side SDK initializes the bootstrapped payload
- The client-side SDK evaluates the flags and sends events back to LaunchDarkly
Configure the Vercel integration to use this SDK successfully. To learn more, read Vercel.The Vercel integration is only available to customers on select plans. To learn more, read about our pricing. To upgrade your plan, contact Sales.
Get started
After you complete the Install a Vercel integration process in an existing project, follow these instructions to start using the LaunchDarkly Vercel SDK:If you are already using Vercel’s Flags SDK, you can use that with your LaunchDarkly feature flags, your Vercel integration, and Vercel’s
@flags-sdk/launchdarkly LaunchDarkly adapter. To learn how, read LaunchDarkly Flags SDK Example in Vercel’s documentation.Install the SDKFirst, install the Vercel SDK as a dependency in your application using your application’s dependency manager. Here’s how:
Initialize the client
After you install and import the SDK, create an edge client using your Edge Config ID. Then, initialize anLDClient using your LaunchDarkly client-side ID and this edge client.
Here’s how:
Evaluate a flag
After you initialize the client, wait for thewaitForInitialization function to resolve. When waitForInitialization is resolved, the client can serve feature flags.
Using the client, you can check which variation a particular context will receive for a given feature flag. In your Vercel Edge application, place the variation code so that it is invoked as needed.
Here is an example:
Bootstrap flags with Next.js
If you are using Next.js with Vercel, you can bootstrap feature flags on the Root Layout for use in the LaunchDarkly React Web SDK. To bootstrap flags, specify the root layout’s runtime with a value ofedge and pass the flags to a client component that initializes the LaunchDarkly React SDK.The Vercel SDK’s GitHub repository contains an example application that takes advantage of bootstrapping flags from the edge for use in the LaunchDarkly React Web SDK.
Promises and async
All asynchronous SDK methods that return aPromise are compatible with then/catch or async/await. You can use either.