# @solana/rpc-subscriptions-channel-websocket

> An RPC Subscriptions transport that uses WebSockets

Latest version **8.3.0** (published 2026-09-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @solana/rpc-subscriptions-channel-websocket
pnpm add @solana/rpc-subscriptions-channel-websocket
yarn add @solana/rpc-subscriptions-channel-websocket
bun add @solana/rpc-subscriptions-channel-websocket
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 8.3.0 |
| Published | 2026-09-09 |
| First published | 2024-10-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20.18.0 |
| Dependencies | 5 |
| Unpacked size | 102.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 696 |
| Author | Solana Labs Maintainers |
| Maintainers | solana-devs |
| Keywords | blockchain, solana, web3 |

## Links

- npm: https://www.npmjs.com/package/@solana/rpc-subscriptions-channel-websocket
- Repository: https://github.com/anza-xyz/kit
- Homepage: https://www.solanakit.com/api#solanarpc-subscriptions-channel-websocket
- Issues: https://github.com/anza-xyz/kit/issues
- npm.io page: https://npm.io/package/@solana/rpc-subscriptions-channel-websocket

## Dependencies (5)

- [ws](https://npm.io/package/ws.md) ^8.21.3
- [@solana/errors](https://npm.io/package/@solana/errors.md) 8.3.0
- [@solana/functional](https://npm.io/package/@solana/functional.md) 8.3.0
- [@solana/subscribable](https://npm.io/package/@solana/subscribable.md) 8.3.0
- [@solana/rpc-subscriptions-spec](https://npm.io/package/@solana/rpc-subscriptions-spec.md) 8.3.0

## Recent versions

- 8.3.0 (latest) — 2026-09-09
- 8.4.0-canary-20260925083045 (canary) — 2026-09-25
- 5.1.0-experimental-20251205104522 (experimental) — 2025-12-05
- 4.0.0 (4x) — 2025-10-08
- 3.0.3 (3x) — 2025-09-11
- 2.0.0 (next) — 2024-11-07
- 2.0.0-rc.4 (rc) — 2024-11-05
- 8.4.0-canary-20260924083259 — 2026-09-24
- 8.4.0-canary-20260923083123 — 2026-09-23
- 8.4.0-canary-20260922155338 — 2026-09-22
- 8.4.0-canary-20260922151509 — 2026-09-22
- 8.4.0-canary-20260922084122 — 2026-09-22
- 8.4.0-canary-20260922083419 — 2026-09-22
- 8.4.0-canary-20260921145441 — 2026-09-21
- 8.4.0-canary-20260921085643 — 2026-09-21
- … 1141 more at https://npm.io/package/@solana/rpc-subscriptions-channel-websocket/versions

## README

[![npm][npm-image]][npm-url]
[![npm-downloads][npm-downloads-image]][npm-url]
<br />
[![code-style-prettier][code-style-prettier-image]][code-style-prettier-url]

[code-style-prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square
[code-style-prettier-url]: https://github.com/prettier/prettier
[npm-downloads-image]: https://img.shields.io/npm/dm/@solana/rpc-subscriptions-channel-websocket?style=flat
[npm-image]: https://img.shields.io/npm/v/@solana/rpc-subscriptions-channel-websocket?style=flat
[npm-url]: https://www.npmjs.com/package/@solana/rpc-subscriptions-channel-websocket

# @solana/rpc-subscriptions-channel-websocket

This package allows developers to create custom RPC Subscriptions channels. Using these primitives, developers can create custom channels that perform transforms on messages sent and received, perform autopings, and implement custom channel pooling strategies.

## Functions

### `createWebSocketChannel()`

Creates an object that represents an open channel to a `WebSocket` server.

You can use it to send messages by calling its `send()` function and you can receive them by subscribing to the `RpcSubscriptionChannelEvents` it emits.

```ts
import { createWebSocketChannel } from '@solana/rpc-subscriptions-channel-websocket';

const abortController = new AbortController();
const webSocketChannel = await createWebSocketChannel({
    sendBufferHighWatermark: Number.POSITIVE_INFINITY,
    signal: abortController.signal,
    url: 'wss://api.mainnet-beta.solana.com',
});
const channel = {
    ...webSocketChannel,
    on(type, listener, options) {
        if (type !== 'message') {
            return webSocketChannel.on(type, listener, options);
        }
        return webSocketChannel.on(
            'message',
            function deserializingListener(message: string) {
                const deserializedMessage = JSON.parse(message);
                listener(deserializedMessage);
            },
            options,
        );
    },
    send(message) {
        const serializedMessage = JSON.stringify(message);
        return webSocketChannel.send(serializedMessage);
    },
} as RpcSubscriptionsChannel<unknown, unknown>;
channel.on(
    'error',
    e => {
        console.log('Received error', e);
        abortController.abort();
    },
    { signal: abortController.signal },
);
channel.on(
    'message',
    m => {
        console.log('Received message', m);
        abortController.abort();
    },
    { signal: abortController.signal },
);
await channel.send({ id: 1, jsonrpc: '2.0', method: 'getSlot' });
```

#### Config

##### `sendBufferHighWatermark`

The number of bytes to admit into the WebSocket's send buffer before queueing messages on the client.

When you call `send()` on a `WebSocket` the runtime might add the message to a buffer rather than send it right away. In the event that `socket.bufferedAmount` exceeds the value configured here, messages will be added to a queue in your application code instead of being sent to the WebSocket, until such time as the `bufferedAmount` falls back below the high watermark.

##### `signal`

An `AbortSignal` to fire when you want to explicitly close the `WebSocket`.

If the channel is open it will be closed with the code `1000`, representing a normal closure. If the channel has not been established yet, firing this signal will result in the `AbortError` being thrown to the caller who was trying to open the channel.

##### `url`

A string representing the target endpoint. In Node, it must be an absolute URL using the `ws` or `wss` protocol.

---
_Source: https://npm.io/package/@solana/rpc-subscriptions-channel-websocket · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
