> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.getunleash.io/guides/unleash-edge-quickstart/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.getunleash.io/_mcp/server. # Unleash Edge quickstart > Set up Unleash Edge locally to reduce feature flag latency, connect SDKs, configure tokens, and verify your setup. This document helps you get started with [Unleash Edge](/unleash-edge) locally. ## Why Unleash Edge Unleash Edge is a lightweight layer between your SDKs and your Unleash instance. It exposes the same HTTP interface as the main [Unleash API](/api) but is built for higher throughput and lower latency. #### Performance & UX Unleash Edge helps you reduce latency for flag resolution by running closer to your users. For example, Unleash Edge could run on a global content-delivery network (CDN) or as part of your cloud or on-premises infrastructure. Setting up one or more Edge nodes helps you distribute traffic and reduce the load on your Unleash instance. By default, Unleash Edge relies on in-memory caching, but you can configure it to use Redis or the local filesystem. #### Security & resilience From a security standpoint, Unleash Edge lets you expose a single, SDK-compatible endpoint without opening your Unleash instance to the public, thus reducing the attack surface. At the same time, Unleash Edge provides an additional layer of resilience, so brief upstream hiccups don't disrupt feature delivery. Optionally, you can set up multiple layers between your application and the Unleash instance (daisy-chaining). This lets you define the optimal configuration for caching and resilience, while adapting Unleash Edge to your architecture's topology. #### Offline mode Unleash Edge can also run in [offline mode](https://github.com/Unleash/unleash-edge/tree/main/examples), so it doesn't need a connection to an upstream Unleash instance. This simplifies local development and helps in environments with limited connectivity. ## Prerequisites Here's what you need before getting started: 1. An [Unleash instance](/get-started/quickstart) running locally or remotely (version `4.15` or later) 2. A valid [API token](/concepts/api-tokens-and-client-keys) for your Unleash instance 3. [Docker](https://www.docker.com/get-started/) installed and running 4. Your preferred Unleash SDK in a [sample app](https://github.com/Unleash/unleash-sdk-examples) ## Run Unleash Edge locally First, make sure your Unleash instance is running (locally or remotely) and generate a new backend API token. #### GitHub Release installer You can install prebuilt binaries for your OS directly from GitHub Releases: ```shell curl --proto '=https' --tlsv1.2 -LsSf https://github.com/Unleash/unleash-edge/releases/download//unleash-edge-installer.sh | sh ``` > **Info** > > Make sure to replace `` with a valid GitHub Release tag such as `v20.1.0`. > > You can pick a valid version from the list of [releases on GitHub](https://github.com/Unleash/unleash-edge/releases). Then launch it: ```shell unleash-edge edge \ --strict \ --upstream-url \ --tokens '' ``` #### Rust toolchain If you're comfortable with the Rust toolchain, install the CLI with [cargo binstall](https://github.com/cargo-bins/cargo-binstall?tab=readme-ov-file#installation) (or [from source](https://github.com/Unleash/unleash-edge#building-from-source)): ```shell cargo binstall unleash-edge ``` Then launch it: ```shell unleash-edge edge \ --strict \ --upstream-url \ --tokens '' ``` #### Docker Launch Unleash Edge locally with Docker: ```shell docker run -it \ -p 3063:3063 \ -e STRICT=true \ -e UPSTREAM_URL= \ -e TOKENS='' \ unleashorg/unleash-edge-enterprise: \ edge ``` > **Info** > > Replace `` with the Enterprise Edge version you want to run. > > You can pick a specific version from the list of [tags on Docker Hub](https://hub.docker.com/r/unleashorg/unleash-edge-enterprise). #### Docker Compose Launch the [examples/docker-compose.yml](https://github.com/Unleash/unleash-edge/blob/main/examples/docker-compose.yml) file: ```shell git clone https://github.com/unleash/unleash-edge/ cd unleash-edge/examples docker compose up ``` > **Info** > > Please note that the sample Docker Compose file includes a Redis service for caching. > In case you want to run Unleash Edge without Redis, make sure to remove the `REDIS_URL` environment variable and the Redis service. ### Required parameters Let's break down the parameters you need to replace in the launch command. #### `` #### GitHub Release installer This is the URL of your Unleash instance. Use the base URL, e.g. `https://app.unleash-hosted.com/testclient` or `http://localhost:4242`. #### Rust toolchain This is the URL of your Unleash instance. Use the base URL, e.g. `https://app.unleash-hosted.com/testclient` or `http://localhost:4242`. #### Docker This is the URL of your Unleash instance. Use the base URL, e.g. `https://app.unleash-hosted.com/testclient`. > **Warning** > > When using Docker with a local Unleash instance, `localhost` refers to the container itself, so you cannot reference your Unleash instance with `http://localhost:4242`. > You'll need to use a different hostname, depending on where the Unleash instance is running. #### Solution 1: use host.docker.internal The easiest solution when using Docker Desktop is to reference the host as `host.docker.internal`. On Linux, you also need to define the host with `--add-host=host.docker.internal:host-gateway`, or just use `--network=host`. Then you can set your upstream URL to `http://host.docker.internal:4242`. #### Solution 2: use a custom network If Unleash runs locally on Docker as well, you could run both containers on the same network. When launching Unleash with `docker compose up`, you could use the [default Compose network](https://docs.docker.com/compose/how-tos/networking/) named `unleash_default` and reference the instance as `web`. Your launch command becomes `--network unleash_default -e UPSTREAM_URL=http://web:4242`. If you prefer decoupling the network and service names, create a custom network: ```shell # define custom network docker network create unleash-net # launch Unleash docker run -d --name unleash --network unleash-net .... # launch Unleash Edge docker run -it --network unleash-net -e UPSTREAM_URL=http://unleash:4242 .... ``` #### Docker Compose This parameter is managed for you in the Docker Compose file. Both containers run on the same network, therefore the instance is referenced using the service name: `http://unleash:4242`. --- #### `` #### GitHub Release installer This API token is required in strict mode, which is recommended since `v19.2`. You can generate a new API token by visiting your Unleash instance, under **Admin settings > Access control > API access**. Click **New API token**, give it a name, and confirm the default values. Note: make sure you keep the single quotes in `--tokens '...'` so the `*` isn't expanded by your shell. #### Rust toolchain This API token is required in strict mode, which is recommended since `v19.2`. You can generate a new API token by visiting your Unleash instance, under **Admin settings > Access control > API access**. Click **New API token**, give it a name, and confirm the default values. Note: make sure you keep the single quotes in `--tokens '...'` so the `*` isn't expanded by your shell. #### Docker This API token is required in strict mode, which is recommended since `v19.2`. You can generate a new API token by visiting your Unleash instance, under **Admin settings > Access control > API access**. Click **New API token**, give it a name, and confirm the default values. Note: make sure you keep the single quotes in `-e TOKENS='...'` so the `*` isn't expanded by your shell. #### Docker Compose This parameter is managed for you in the Docker Compose file. You can customize the default tokens by editing the Unleash environment variables: ```yaml services: unleash: environment: INIT_FRONTEND_API_TOKENS: "default:development.unleash-insecure-frontend-api-token" INIT_CLIENT_API_TOKENS: "default:development.unleash-insecure-api-token" ``` Unleash Edge is automatically configured with the same backend token. ## Update your application code Before you continue, make sure Unleash Edge is running on port `3063`. You can verify this by fetching `http://localhost:3063/internal-backstage/health`. This endpoint should respond with `{"status":"OK"}`. Then you can start updating your application: 1. Identify the code or configuration file where the Unleash instance URL is defined. 2. Update the SDK configuration to use `http://localhost:3063`. 3. Make sure the SDK configuration includes a valid API token. 4. Restart your app and test it. #### .NET For example, if you're using the [.NET example](https://github.com/Unleash/unleash-sdk-examples/tree/main/.NET), update the API URL and token in your `.env` file: **`.env`** ```text title=".env" UNLEASH_API_URL=http://localhost:3063/api UNLEASH_API_TOKEN= ``` #### Android For example, if you're using the [Android example](https://github.com/Unleash/unleash-sdk-examples/tree/main/Android): **`app/src/main/java/com/example/myapplication/MyApplication.kt`** ```kotlin {4-5} title="app/src/main/java/com/example/myapplication/MyApplication.kt" val instance = DefaultUnleash( androidContext = this, unleashConfig = UnleashConfig.newBuilder(appName = "codesandbox-android") .proxyUrl("http://10.0.2.2:3063/api/frontend/") .clientKey("") .build() ) ``` > **Warning** > > Please note that you need to use the `10.0.2.2` IP address from the Android emulator to access `localhost`. #### Flutter For example, if you're using the [Flutter example](https://github.com/Unleash/unleash-sdk-examples/tree/main/Flutter): **`unleash_example/lib/main.dart`** ```dart {2-3} title="unleash_example/lib/main.dart" var unleash = UnleashClient( url: Uri.parse('http://localhost:3063/api/frontend/'), clientKey: '', refreshInterval: 5, appName: 'local-flutter', ); ``` > **Warning** > > Please note that you need to use the `10.0.2.2` IP address from the Android emulator to access `localhost`. > > You can use `localhost` from the iOS emulator without issues. > > When using a real iOS device, you need to use your computer's IP address. Run `ipconfig` on Windows or `ifconfig` on Linux/macOS to identify your IP address. #### Go For example, if you're using the [Go example](https://github.com/Unleash/unleash-sdk-examples/tree/main/Go), update the API URL and token in your `.env` file: **`.env`** ```text title=".env" UNLEASH_API_URL=http://localhost:3063/api UNLEASH_API_TOKEN= ``` #### Java For example, if you're using the [Java example](https://github.com/Unleash/unleash-sdk-examples/tree/main/Java): **`src/main/java/Main.java`** ```java {2-3} title="src/main/java/Main.java" var flag = "example-flag"; var url = "http://localhost:3063/api/"; var token = ""; ``` #### JavaScript For example, if you're using the [JavaScript example](https://github.com/Unleash/unleash-sdk-examples/tree/main/JavaScript): **`src/index.js`** ```javascript {2-3} title="src/index.js" const unleash = new UnleashClient({ url: "http://localhost:3063/api/frontend/", clientKey: "", appName: "javascript-codesandbox", }); ``` #### Next.js For example, if you're using the [Next.js example](https://github.com/Unleash/unleash-sdk-examples/tree/main/Next.js), update the API URL and token in your `.env` file: **`.env`** ```text title=".env" NEXT_PUBLIC_UNLEASH_SERVER_API_URL=http://localhost:3063/api NEXT_PUBLIC_UNLEASH_FRONTEND_API_TOKEN= ``` #### Node.js For example, if you're using the [Node.js example](https://github.com/Unleash/unleash-sdk-examples/tree/main/Node.js), update the API URL and token in your `.env` file: **`.env`** ```text title=".env" UNLEASH_API_URL=http://localhost:3063/api UNLEASH_API_TOKEN= ``` #### PHP For example, if you're using the [PHP example](https://github.com/Unleash/unleash-sdk-examples/tree/main/PHP), update the API URL and token in your `.env` file: **`.env`** ```text title=".env" UNLEASH_API_URL=http://localhost:3063/api UNLEASH_API_TOKEN= ``` #### Python For example, if you're using the [Python example](https://github.com/Unleash/unleash-sdk-examples/tree/main/Python), update the API URL and token in your `.env` file: **`.env`** ```text title=".env" UNLEASH_API_URL=http://localhost:3063/api UNLEASH_API_TOKEN= ``` #### React For example, if you're using the [React example](https://github.com/Unleash/unleash-sdk-examples/tree/main/React): **`src/index.tsx`** ```tsx {3-4} title="src/index.tsx" ", refreshInterval: 15, appName: "codesandbox-react", }} > ``` #### Ruby For example, if you're using the [Ruby example](https://github.com/Unleash/unleash-sdk-examples/tree/main/Ruby), update the API URL and token in your `.env` file: **`.env`** ```text title=".env" UNLEASH_API_URL=http://localhost:3063/api UNLEASH_API_TOKEN= ``` #### Rust For example, if you're using the [Rust example](https://github.com/Unleash/unleash-sdk-examples/tree/main/Rust), update the API URL and token in your `.env` file: **`.env`** ```text title=".env" UNLEASH_API_URL=http://localhost:3063/api UNLEASH_API_TOKEN= ``` #### Svelte For example, if you're using the [Svelte example](https://github.com/Unleash/unleash-sdk-examples/tree/main/Svelte): **`src/routes/+layout.svelte`** ```javascript {2-3} title="src/routes/+layout.svelte" const config = { url: 'http://localhost:3063/api/frontend/', clientKey: '', refreshInterval: 5, metricsInterval: 5, appName: 'codesandbox-svelte' }; ``` #### Swift For example, if you're using the [Swift example](https://github.com/Unleash/unleash-sdk-examples/tree/main/Swift): **`Sources/UnleashExample/main.swift`** ```swift {2-3} title="Sources/UnleashExample/main.swift" var unleashClient = UnleashProxyClientSwift.UnleashClientBase( unleashUrl: "http://localhost:3063/api/frontend/", clientKey: "", refreshInterval: 15, appName: "codesandbox-swift", context: [:] ) ``` > **Warning** > > Please note that you can use `localhost` from the iOS emulator without issues. > > When using a real iOS device, you need to use your computer's IP address. Run `ipconfig` on Windows or `ifconfig` on Linux/macOS to identify your IP address. #### Vue For example, if you're using the [Vue example](https://github.com/Unleash/unleash-sdk-examples/tree/main/Vue): **`src/App.vue`** ```javascript {2-3} title="src/App.vue" const config = { url: 'http://localhost:3063/api/frontend/', clientKey: '', refreshInterval: 5, metricsInterval: 5, appName: 'codesandbox-vue' } ``` ## Verify your setup If you run into issues while connecting your SDK to Unleash Edge, the following commands can help you identify the problem. ```shell # is the local Unleash instance running correctly? curl http://localhost:4242/health # is the local Unleash Edge instance running correctly? curl http://localhost:3063/internal-backstage/health # or via CLI unleash-edge health # is data going through? is my token valid? curl -H "Authorization: " http://localhost:3063/api/client/features ``` You might encounter some of these common issues: * If Unleash Edge logs show *"connection refused"* to `127.0.0.1:4242` within Docker, you're pointing at `localhost` inside the container. Use `host.docker.internal` or a shared Docker network instead. * If Unleash Edge logs show *"Edge was not able to validate any of the tokens configured at startup"* make sure you're using a valid backend token in your startup command. * If your SDK logs show *"401/invalid token"* ensure you're using a valid token from your Unleash instance that matches the environment and project you expect. ## Next steps Congratulations, you've successfully set up Unleash Edge locally! Unleash Edge offers a lot of flexibility and advanced configuration options worth exploring: 1. [Offline mode](/unleash-edge/deploy#modes-of-operation) - Learn how to configure Unleash Edge to work without an Unleash instance, using a local features file. 2. [Pretrusted tokens](/unleash-edge/deploy#pre-trusted-tokens) - Learn how to explicitly authorize known frontend tokens without upstream validation. 3. [Security considerations in production](/unleash-edge/configure#security) - Learn how to run Unleash Edge in production with best practices for CORS, health checks, and sensitive endpoints. 4. [Persistent cache storage](/unleash-edge/deploy#reliability-and-persistence) - Learn how to enable persistent cache storage with options such as `--backup-folder` and `--redis-url`. 5. [Advanced CLI configuration](/unleash-edge/configure) - Learn how to customize the CLI behavior with options such as `--base-path`, `--workers`, `--allow-list`, `--edge-request-timeout`, and `--edge-auth-header`. > Set up Unleash Edge locally to reduce feature flag latency, connect SDKs, configure tokens, and verify your setup.