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

> Register the GitLab npm registry and install the Angular SDK.

The `@westyx-nexus/sdk-angular` package is hosted on the [GitLab npm Package Registry](https://gitlab.com/westyx/nexus/sdk/angular/-/packages). It is **public** - no token is required to install.

## 1. Configure npm to look at the registry

Add (or merge) the following to your project's `.npmrc`:

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

<Info>
  Commit the `.npmrc` to source control. It contains no credentials - every developer on the team automatically picks up the right registry.
</Info>

## 2. Install the package

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

Pin to a specific version:

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

## Requirements

* **Angular 17.0** or newer (standalone or NgModule-based projects both supported)
* **TypeScript 5.4** or newer (transitively via Angular 17)
* A modern browser environment with `fetch` + `ReadableStream` support (all evergreen browsers)
* **Server-side rendering (SSR):** fully supported - stream setup is automatically skipped in non-browser environments

## Use a public API key

<Warning>
  Browser SDKs must use a `wxp_...` (public) key. Secret keys (`wxs_...`) are rejected at runtime.

  public keys are sent as the `X-Nexus-API-Key` header on all requests, including the SSE stream. Secret keys (`wxs_…`) are rejected at SDK initialization time and must never be used in browser environments.
</Warning>

The SDK enforces this via:

1. A **branded TypeScript type** (`PublicApiKey`) - gives you a compile-time hint when you pass an unwrapped string
2. A **runtime guard** in the SDK constructor - throws a descriptive error before any network call
3. A **backend reject** - the `/stream` endpoint returns `400 Bad Request` for secret keys

See the [API reference](api-reference) for examples using `assertPublicKey()`.

## Verifying connectivity

Before writing any code, confirm your endpoint and API key work with a plain `curl`:

```sh theme={null}
curl -s \
  -H "X-Nexus-API-Key: wxp_..." \
  https://your-service.westyx.dev/v1/sync
```

A valid response returns a JSON snapshot with your `configs` and `flags` (browser SDKs use public keys - secrets are never included). An `HTTP 401` means the key is wrong; `HTTP 404` means the slug is wrong.

## Troubleshooting

* **`Could not resolve '@westyx-nexus/sdk-angular'`** - your `.npmrc` is not picked up. Confirm it's at the project root next to `package.json`, and check `npm config get registry @westyx-nexus`.
* **`401 Unauthorized` when running `npm install`** - the registry might be configured with an old path that's no longer valid. Switch to the numeric-ID variant above.
* **`Browser SDKs require a public key`** at runtime - replace your `wxs_...` key with a `wxp_...` key from the same service in the Westyx Nexus admin UI.
