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 Lua SDK, and links to reference information on all of the supported features. We also provide documentation for running the SDK in NGINX and HAProxy.LaunchDarkly’s SDKs are open source. In addition to this reference guide, we provide source, API reference documentation, and sample applications:
| Resource | Location |
|---|---|
| SDK API documentation | SDK API docs |
| Supported SDK Versions | Lua server SDK |
| GitHub repository | lua-server-sdk |
| Sample applications | Lua , Lua with HAProxy , Lua with OpenResty NGINX |
| Published module | LuaRocks |
Get started
After you complete the Getting Started process, follow these steps to get started using the LaunchDarkly SDK in your Lua application. The Lua server-side SDK is implemented using a foreign function interface that calls the C++ server-side SDK. You need to install the C++ server-side SDK dynamic library somewhere accessible by the linker. To learn more, read C++ SDK reference (server-side).Install the SDK
First, include the library:The Lua SDK uses an SDK key. Keys are specific to each project and environment. They are available from Project settings, on the Environments list. To learn more about key types, read Keys.
Initialize the client
After you install and import the SDK, create a single, shared instance ofLDClient. Specify your SDK key here to authorize your application to connect to a particular environment within LaunchDarkly.
Calling clientInit initiates a remote call to the LaunchDarkly service to fetch feature flags. This call blocks up for the time that you provide in milliseconds. If you request a feature flag before the client completes initialization, you will receive the default flag value.
Here is an example:
clientInit.
Evaluate a context
You can useclient to check which variation a particular context will receive for a given feature flag.
Here’s how: