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

# Vue SDK

> Official Vue 3 SDK for Westyx Nexus - composables returning ComputedRefs, plugin teardown.

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

```ts theme={null}
// main.ts
import { createApp } from 'vue';
import { provideNexus } from '@westyx-nexus/sdk-vue';
import App from './App.vue';

const app = createApp(App);
await provideNexus(app, {
  baseUrl: 'https://blue-ocean-a5rx7.westyx.dev',
  apiKey:  'wxp_...',
});
app.mount('#app');
```

```vue theme={null}
<!-- App.vue -->
<script setup lang="ts">
import { useConfig, useFlag } from '@westyx-nexus/sdk-vue';

const banner = useConfig<string>('public.banner');
const isV2   = useFlag('checkout.v2', false);
</script>

<template>
  <h1>{{ isV2 ? 'Checkout v2' : 'Checkout' }}</h1>
  <p>{{ banner }}</p>
</template>
```

## What's new in v0.10.0

* Version alignment across the Westyx Nexus SDK suite.

## What's new in v0.8.0

* **`@westyx-nexus/openfeature-provider-vue`** - OpenFeature bridge provider wrapping an existing `NexusClient`. Emits `ConfigurationChanged` on every cache update; exposes flags as boolean evaluations and configs as string/number/object evaluations.

## What's new in v0.4.1

* **Fetch-based SSE stream** - the live-update connection now uses `fetch` + `ReadableStream` instead of `EventSource`. The API key is sent as `X-Nexus-API-Key` header and no longer appears in the stream URL as `?key=`, keeping it out of server access logs and browser history.
* **Security improvements** - response bodies are scrubbed from all error paths; `NexusError.cause` is non-enumerable so error chains do not appear in `JSON.stringify` output.
* **Network hardening** - all `fetch` calls now carry `AbortSignal.timeout(30 s)`; `response.json()` is wrapped in `try/catch` to handle malformed 200 responses gracefully.
* **Reliability fix** - the SSE error counter is reset when `connectStream()` is called after a max-error fallback, so reconnects start from zero rather than immediately re-triggering the fallback.
* **CI improvements** - tests run on every MR and `main` push; publish is restricted to semver tags.

## What's new in v0.4.0

* **Path prefix change** - all API paths updated from `/api/v1/` to `/v1/` (`/v1/sync`, `/v1/stream`, `/v1/flags/evaluate-ab`).
* **`NexusQuarantinedError`** - new error class thrown when the server returns 429 with `{"error":"quarantined"}` body. Carries `reason` (string) and `expiresAt` (Date). The SDK pauses background sync until `expiresAt`.
* **`onQuarantined(reason, expiresAt)` observer hook** - fires for both sync and SSE pre-flight quarantine 429 responses.
* **`is_public` removed from `ConfigEntry`** - the field has been removed from the sync response schema.

## What's new in v0.3.1

* **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.
* **Plugin teardown** - both `createNexusPlugin().install` and `provideNexus()` now wrap the host `app.unmount()` to call `client.disconnectStream()` on teardown. Prevents leaked SSE connections during HMR and SSR app teardown.
* **`FALLBACK_REASON_RATE_LIMITED` value aligned** - the exported constant's value changed from `'rate_limited'` (underscore) to `'rate-limited'` (kebab) for parity with the Angular / React / Node SDKs.

## Highlights

* **Vue 3.3+** - Composition API only, single package, zero external runtime dependencies (fetch-based SSE with `ReadableStream` + `AbortController`, not the browser `EventSource` API)
* **`provideNexus()` blocking initial sync** - `await` it before `app.mount()` so children never render against an empty cache
* **Reactive composables** returning `ComputedRef`s - Vue's reactivity system automatically re-renders components when the cache changes
* **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
* **public-key enforcement** - browser SDKs must use a public key; secret keys are rejected at runtime
* **Stream observer hooks** *(v0.2.0)* - structured callbacks for SSE lifecycle events

<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/vuejs/-/packages). Install:

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

<Note>
  The npm package name is `@westyx-nexus/sdk-vue` (no `js` suffix), while the GitLab project is `westyx/nexus/sdk/vuejs`. They're independent - npm scope is a brand identifier, GitLab path is a repo location.
</Note>

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

## Pages

| Page                                 | Description                                                            |
| ------------------------------------ | ---------------------------------------------------------------------- |
| [Installation](installation)         | Register the GitLab npm registry and install                           |
| [Configuration](configuration)       | `NexusConfig` field reference                                          |
| [API reference](api-reference)       | Every composable and imperative method                                 |
| [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)   | `NexusStreamObserver` reference                                        |
| [OpenFeature](openfeature)           | OpenFeature bridge provider (`@westyx-nexus/openfeature-provider-vue`) |
