> ## 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 bridge

> Use @westyx-nexus/openfeature-provider-angular to wire the Angular SDK into the OpenFeature Web SDK.

The `@westyx-nexus/openfeature-provider-angular` sub-package provides an [OpenFeature](https://openfeature.dev) `Provider` that wraps an existing `NexusClient` from `@westyx-nexus/sdk-angular`.

**No second SSE connection is opened.** The bridge subscribes to the same `NexusClient` that the rest of your app uses. Whenever the client replaces its in-memory snapshot (TTL poll or SSE push), the provider emits `ProviderEvents.ConfigurationChanged` so the OpenFeature SDK re-evaluates all flags.

## Installation

```sh theme={null}
npm install @westyx-nexus/openfeature-provider-angular @openfeature/web-sdk
```

Add the GitLab npm registry to your `.npmrc`:

```ini theme={null}
@westyx-nexus:registry=https://gitlab.com/api/v4/projects/81978897/packages/npm/
```

## Wiring up in `app.config.ts`

```ts theme={null}
import { ApplicationConfig, APP_INITIALIZER, inject } from '@angular/core';
import { OpenFeature } from '@openfeature/web-sdk';
import { provideNexus, NexusClient } from '@westyx-nexus/sdk-angular';
import { createOpenFeatureProvider } from '@westyx-nexus/openfeature-provider-angular';

export const appConfig: ApplicationConfig = {
  providers: [
    // 1. Nexus is initialized as usual via APP_INITIALIZER (blocking sync)
    provideNexus({
      baseUrl: 'https://blue-ocean-a5rx7.westyx.dev',
      apiKey: 'wxp_...',
    }),
    // 2. OpenFeature is wired up after Nexus is ready
    {
      provide: APP_INITIALIZER,
      useFactory: () => {
        const nexus = inject(NexusClient);
        return () => OpenFeature.setProviderAndWait(createOpenFeatureProvider(nexus));
      },
      multi: true,
    },
  ],
};
```

The `APP_INITIALIZER` ensures Nexus populates its cache before Angular renders, and `setProviderAndWait` completes before OpenFeature client calls are made.

## Reading flags in a component

Using `@openfeature/angular-sdk`:

```ts theme={null}
import { useBooleanFlagValue } from '@openfeature/angular-sdk';

@Component({ ... })
export class MyComponent {
  showBanner = useBooleanFlagValue('banner.enabled', false);
}
```

Or using the raw OpenFeature client:

```ts theme={null}
import { OpenFeature } from '@openfeature/web-sdk';

const client = OpenFeature.getClient();
const showBanner = client.getBooleanValue('banner.enabled', false);
```

## NgModule-based apps

```ts theme={null}
import { NgModule } from '@angular/core';
import { APP_INITIALIZER, inject } from '@angular/core';
import { OpenFeature } from '@openfeature/web-sdk';
import { NexusModule, NexusClient } from '@westyx-nexus/sdk-angular';
import { createOpenFeatureProvider } from '@westyx-nexus/openfeature-provider-angular';

@NgModule({
  imports: [
    NexusModule.forRoot({
      baseUrl: 'https://blue-ocean-a5rx7.westyx.dev',
      apiKey: 'wxp_...',
    }),
  ],
  providers: [
    {
      provide: APP_INITIALIZER,
      useFactory: () => {
        const nexus = inject(NexusClient);
        return () => OpenFeature.setProviderAndWait(createOpenFeatureProvider(nexus));
      },
      multi: true,
    },
  ],
})
export class AppModule {}
```

## Flag resolution

| OpenFeature method              | Nexus lookup                   | Result                                                                                  |
| ------------------------------- | ------------------------------ | --------------------------------------------------------------------------------------- |
| `getBooleanValue(key, default)` | `client.getFlag(key, default)` | Always `STATIC` reason                                                                  |
| `getStringValue(key, default)`  | `client.getConfig(key)`        | `STATIC` if found + string; `FLAG_NOT_FOUND` if absent; `TYPE_MISMATCH` if not a string |
| `getNumberValue(key, default)`  | `client.getConfig(key)`        | `STATIC` if found + numeric; coerces numeric strings; `TYPE_MISMATCH` on NaN            |
| `getObjectValue(key, default)`  | `client.getConfig(key)`        | `STATIC` if found + object; `TYPE_MISMATCH` if primitive                                |

Boolean flags use `getFlag()` (which returns `is_active` and applies a default). String, number, and object evaluations use `getConfig()`.

## Live updates

The provider calls `client.subscribe(listener)` in `initialize()`. When the `NexusClient` replaces its snapshot (after TTL expiry or an SSE push event), the listener fires and the provider emits `ProviderEvents.ConfigurationChanged`. The OpenFeature SDK re-evaluates all flag clients, and UI using `@openfeature/angular-sdk` re-renders automatically.

`onClose()` unsubscribes the listener cleanly.

## Latest release

**v0.10.0** - published 2026-07-05.

Install:

```sh theme={null}
npm install @westyx-nexus/openfeature-provider-angular@0.10.0
```
