This SDK is in betaDevelopment work on the Fastly SDK is ongoing. The SDK is fully tested and we consider it production-ready, however, we are actively soliciting feedback on its usage. Some external APIs could change prior to the v1 release.
SDK quick linksLaunchDarkly’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 | Fastly SDK |
| GitHub repository | LaunchDarkly Fastly SDK |
| Sample application | Example app |
| Published module | npm |
This SDK requires LaunchDarkly’s Fastly integrationConfigure the Fastly integration to use this SDK successfully. To learn more, read Fastly.The Fastly 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 Create a Fastly integration process in an existing project, follow these instructions to start using the LaunchDarkly Fastly SDK:Install the SDK
First, install the Fastly 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, configure a Fastly KV Store. Then, initialize anLDClient using your LaunchDarkly client-side ID, the Fastly KV store name, and the Fastly events backend name. The client must be initialized when processing requests, not during build-time initialization.
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 Fastly application, place the variation code so that it is invoked as needed.
Here is an example: