> ## Documentation Index
> Fetch the complete documentation index at: https://docs.westyx.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenFeature integration

> Use the Westyx Nexus Kotlin SDK as an OpenFeature provider.

The `nexus-kotlin-openfeature` artifact wraps `NexusClient` behind the
[OpenFeature](https://openfeature.dev) Java SDK standard. Install it alongside the main SDK
when your team uses the OpenFeature API.

## Installation

```kotlin theme={null}
// build.gradle.kts
dependencies {
    implementation("dev.westyx.nexus:nexus-kotlin-sdk:0.10.0")
    implementation("dev.westyx.nexus:nexus-kotlin-openfeature:0.10.0")
}
```

## Register the provider

```kotlin theme={null}
import dev.openfeature.sdk.OpenFeatureAPI
import dev.westyx.nexus.openfeature.NexusProvider

// client is your already-initialized NexusClient
OpenFeatureAPI.getInstance().setProvider(NexusProvider(client))
```

## Usage

```kotlin theme={null}
import dev.openfeature.sdk.MutableContext
import dev.openfeature.sdk.OpenFeatureAPI

val ofClient = OpenFeatureAPI.getInstance().getClient("my-service")
val ctx = MutableContext()

val darkMode  = ofClient.getBooleanValue("dark-mode", false, ctx)
val apiUrl    = ofClient.getStringValue("api.base-url", "https://default.example.com", ctx)
val rateLimit = ofClient.getDoubleValue("rate-limit", 100.0, ctx)
val maxItems  = ofClient.getIntegerValue("max-items", 50, ctx)
```

## Evaluation behaviour

| OpenFeature type | Nexus source                                              | Miss                     | Wrong type     |
| ---------------- | --------------------------------------------------------- | ------------------------ | -------------- |
| `Boolean`        | `NexusClient.getFlag(key, default)`                       | Returns default (STATIC) | n/a            |
| `String`         | `NexusClient.getJson(key)` - `JsonPrimitive.isString`     | FLAG\_NOT\_FOUND         | TYPE\_MISMATCH |
| `Double`         | `NexusClient.getJson(key)` - unquoted numeric             | FLAG\_NOT\_FOUND         | TYPE\_MISMATCH |
| `Integer`        | `NexusClient.getJson(key)` - unquoted numeric (truncated) | FLAG\_NOT\_FOUND         | TYPE\_MISMATCH |
| `Object`         | `NexusClient.getJson(key)` - any `JsonElement`            | FLAG\_NOT\_FOUND         | n/a            |

`EvaluationContext` is accepted but ignored - Nexus has no per-user targeting.
All successful evaluations return `STATIC` reason.
