Akamai SDK reference
Read time: 5 minutes
Last edited: Dec 14, 2024
Overview
This topic documents how to get started with the Akamai 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 |
GitHub repository | LaunchDarkly Akamai SDK |
The Akamai SDK is designed to be used with one of the LaunchDarkly client-side SDKs as follows:
- The Akamai 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
If you are using Akamai EdgeKV, configure the Akamai integration to use this SDK successfully. To learn more, read Akamai.
The Akamai integration is only available to customers on select plans. To learn more, read about our pricing. To upgrade your plan, contact Sales.
If you are using Akamai's EdgeWorkers, but not using the Akamai EdgeKV, the Akamai integration is not required.
Get started
After you complete the Create an Akamai integration process in an existing project, follow these instructions to start using the LaunchDarkly Akamai SDK if you are using Akamai EdgeKV:
Most customers use the Akamai EdgeKV and the Akamai integration. If you are using Akamai's EdgeWorkers, but not using the Akamai EdgeKV store, you can use the LaunchDarkly Akamai SDK to access your own feature store instead. If you are using your own feature store, skip to Using Akamai EdgeWorkers with your own feature store, below.
Install the SDK
Install the Akamai SDK as a dependency in your application using your application's dependency manager:
Then, import the init
method in your application code:
Initialize the client
After you install and import the SDK, initialize the client with your LaunchDarkly SDK client-side ID and the namespace and group from your Akamai EdgeKV. These should be the same namespace and group that you used to configure the Akamai integration.
Here's how:
The Akamai SDK uses a client-side ID to associate the LaunchDarkly environment with the CDN integration. Client-side IDs are specific to each project and environment. They are available from the Environments list for each project. To learn more about key types, read Keys.
Evaluate a flag
Using the client, check which variation a particular context will receive for a given feature flag:
Using Akamai EdgeWorkers with your own feature store
Expand for instructions if you are using Akamai EdgeWorkers with a non-EdgeKV store
Most customers use the Akamai EdgeKV and the Akamai integration. If you are using Akamai's EdgeWorkers, but not using the Akamai EdgeKV store, you can use the LaunchDarkly Akamai SDK to access your own feature store instead. However, the package and method names are slightly different. Additionally, you are responsible for putting flag data into your EdgeWorker. LaunchDarkly does not provide an integration for this.
To install and configure the Akamai SDK if you are using Akamai EdgeWorkers with a non-EdgeKV store:
-
Install the Akamai SDK as a dependency in your application using your application's dependency manager:
-
Import the
init
method in your application code: -
Create a new class that implements
EdgeProvider
. It should take a key, formatted asLD-Env-{your LaunchDarkly client-side ID for this environment}
. It should return a promise to return flag data. To learn more about how to retrieve and store flag data, read Create a flag data file. To learn more, readEdgeProvider
.Here's an example:
-
After you install and import the SDK, initialize the client with your LaunchDarkly SDK client-side ID and an instance of the class you created in the previous step.
Here's how:
-
Using the client, check which variation a particular context will receive for a given feature flag:
Promises and async
All asynchronous SDK methods that return a Promise
are compatible with then/catch
or async/await
. You can use either.
Shut down the client
In the Akamai SDK, the client will be automatically closed when your application terminates.
Supported features
This SDK supports the following features: