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

# TypeScript

> The @radion-app/sdk TypeScript package — ESM + CJS, fully typed.

[`@radion-app/sdk`](https://www.npmjs.com/package/@radion-app/sdk) is the TypeScript SDK. It ships both ESM and CommonJS builds and brings its own types. It has few dependencies — just `ws` and `zod`. Needs Node.js 18+.

```bash theme={null}
pnpm add @radion-app/sdk
```

## Usage

```typescript theme={null}
import { Radion } from "@radion-app/sdk";

const radion = new Radion({ apiKey: process.env.RADION_API_KEY });

await radion.realtime.connect();
radion.realtime.subscribe({ id: "trading", channel: "trading" });
radion.realtime.onChannel("trading", (event) =>
  console.log(event.id, event.data)
);
```

## Modules

Both module systems load from the package `exports`:

```typescript theme={null}
import { Radion } from "@radion-app/sdk"; // ESM
```

```javascript theme={null}
const { Radion } = require("@radion-app/sdk"); // CommonJS
```

## Standalone realtime client

If you only need the stream, import `RealtimeClient` on its own:

```typescript theme={null}
import { RealtimeClient } from "@radion-app/sdk";

const client = new RealtimeClient({ apiKey: process.env.RADION_API_KEY });
await client.connect();
```

## Exports

| Export                                                                     | Kind         |
| -------------------------------------------------------------------------- | ------------ |
| `Radion`, `RealtimeClient`                                                 | classes      |
| `RadionError`, `RadionConnectionError`, `RadionServerError`                | errors       |
| `CHANNELS`, `isChannel`                                                    | values       |
| `Channel`, `Subscription`, `ChannelFilters`, `ChannelEvent`                | types        |
| `RadionOptions`, `RealtimeOptions`, `ReconnectOptions`, `HeartbeatOptions` | option types |

`onChannel(name, …)` narrows `event.data` to that channel's typed payload. For the catch-all `events()` stream, use `ChannelEvent<T>` to set the payload type.

## Examples

You can find ready-to-run Node.js + TypeScript examples for every channel in the [WebSocket examples](/websockets/examples).
