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

# Angular SDK

> Official Angular SDK for Westyx Nexus - APP_INITIALIZER blocking sync, NgZone-aware SSE.

Official Angular SDK for [Westyx Nexus](https://westyx.dev) - the centralised secrets, feature flags, and config service.

```ts theme={null}
// app.config.ts
import { ApplicationConfig } from '@angular/core';
import { provideNexus } from '@westyx-nexus/sdk-angular';

export const appConfig: ApplicationConfig = {
  providers: [
    provideNexus({
      baseUrl: 'https://blue-ocean-a5rx7.westyx.dev',
      apiKey:  'wxp_...',
    }),
  ],
};
```

```ts theme={null}
// app.component.ts
import { Component } from '@angular/core';
import { injectNexus } from '@westyx-nexus/sdk-angular';

@Component({ selector: 'app-root', template: `...` })
export class AppComponent {
  private nexus = injectNexus();

  port    = this.nexus.getConfigAs<number>('server.port');
  isNew   = this.nexus.getFlag('checkout.v2', false);
  banner  = this.nexus.getConfig('public.banner') as string | undefined;
}
```

## What's new in v0.10.0

* Version alignment across the Westyx Nexus SDK suite.

## What's new in v0.8.0

* **`NexusClient.subscribe(listener)`** - registers a change listener called after every snapshot replacement (TTL poll or SSE push). Returns an unsubscribe function. Intended for non-Angular consumers such as the OpenFeature bridge.
* **`@westyx-nexus/openfeature-provider-angular`** - new companion sub-package: an OpenFeature `Provider` that wraps an existing `NexusClient`. No second SSE connection is opened. See [OpenFeature bridge](/sdks/angular/openfeature).

## What's new in v0.6.2

* **SSE live-update fix** - event frames sent without a space after the colon (`event:flag.toggled`) are now recognized, so `getFlagSignal()` and the cache update live on every push. Earlier versions only parsed `event: flag.toggled` (with a space) and silently ignored events from the Nexus backend, leaving values frozen at the initial sync. Upgrade to v0.6.2 if you rely on live flag or config updates.

## What's new in v0.6.1

* **`getFlagSignal(key, defaultValue)`** - reactive `Signal<boolean>` for feature flags. Automatically re-evaluates after every SSE push or TTL poll - use this for template bindings instead of `getFlag()` to get live reactivity with no subscription boilerplate.

## What's new in v0.6.0

* **SSE reconnect after polling fallback** - after the SSE stream falls back to TTL polling, the SDK now schedules a reconnect attempt instead of staying on polling indefinitely. The delay is controlled by `sseReconnectCooldown`, expressed in minutes (default `[5, 10, 20, 40, 60]`).

## What's new in v0.4.1

* **Secure SSE stream** - API key sent as a request header; no longer in the URL.
* **SSR support** - stream setup skipped automatically in server-side rendering environments.
* **`NexusTimeoutError`** - typed timeout error for sync and evaluate-ab calls (30 s).
* **Isolated provider state** - `provideNexus()` safe for micro-frontends and parallel test suites.
* **Angular 17+ compatibility confirmed** - peerDependencies set to `>=17.0.0`.

## What's new in v0.3.1

* **5xx sync hardening** - `/sync` 5xx responses now retry with exponential backoff (1 s to 30 s capped) instead of failing silently until the next TTL tick. During the wait the SDK emits `FALLBACK_REASON_TRANSPORT` on the stream observer.
* **429 SSE pre-flight probe** - `connectStream()` now runs a `fetch` pre-flight against the stream URL before opening `EventSource`. On HTTP 429 the SDK parses `Retry-After` (clamped to `[5 s, 300 s]`, default 5 s on miss), emits `FALLBACK_REASON_RATE_LIMITED`, and re-attempts the connect after the indicated delay.
* **New constant** - `FALLBACK_REASON_TRANSPORT` (`'transport'`) is now exported alongside `FALLBACK_REASON_MAX_ERRORS` and `FALLBACK_REASON_RATE_LIMITED`.

## What's new in v0.3.0

* **AB Testing batch evaluation** - new `evaluateAB(keys, userId, attributes)` returning `Observable<Record<string, boolean>>`, plus an `evaluateABPromise(...)` variant for `async/await` call sites.
* **`NexusAbAddonNotAvailableError`** - thrown on HTTP 403 so apps can fall back to `getFlag` when the AB Testing add-on is not active.

## Highlights

* **Angular 17+** - standalone-ready and NgModule-based apps both supported
* **APP\_INITIALIZER blocking sync** - components see a populated cache from first render
* **Thread-safe TTL cache** with atomic snapshot replacement and ETag/304 support
* **SSE live updates** - propagates remote changes within milliseconds; falls back to TTL polling after 3 transport errors
* **Secure SSE streaming** - API key in header, SSR-safe
* **Reactive flag signals** (`getFlagSignal`) - live-updating `Signal<boolean>` for templates *(v0.6.1)*
* **Typed timeout errors** (`NexusTimeoutError`)
* **`NgZone` re-entry** on every event so change detection fires correctly
* **public-key enforcement** - browser SDKs must use a public key; secret keys are rejected at runtime

<Warning>
  Browser SDKs must use a `wxp_...` (public) key. Never embed secret keys (`wxs_...`) in browser code.
</Warning>

## Package

Hosted on the [GitLab npm Package Registry](https://gitlab.com/westyx/nexus/sdk/angular/-/packages). Install:

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

Latest release: **v0.10.0** *(2026-07-05 - version alignment across the Westyx Nexus SDK suite)*.

Compatible with Angular 17 and later. Server-side rendering (SSR) supported.

## Pages

| Page                                 | Description                                              |
| ------------------------------------ | -------------------------------------------------------- |
| [Installation](installation)         | Register the GitLab npm registry and install the package |
| [Configuration](configuration)       | `NexusConfig` field reference                            |
| [API reference](api-reference)       | Every public method, signal, and token                   |
| [Error handling](error-handling)     | Error hierarchy + when each is thrown                    |
| [SSE live updates](sse-live-updates) | How live propagation works in the browser                |
| [Stream observer](stream-observer)   | Opt-in structured callbacks                              |
