# @polkadot-api/ws-provider

> `JsonRpcProvider` to connect to a chain via a WebSocket.

Latest version **0.9.1** (published 2026-07-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @polkadot-api/ws-provider
pnpm add @polkadot-api/ws-provider
yarn add @polkadot-api/ws-provider
bun add @polkadot-api/ws-provider
```

## Health

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

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

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.9.1 |
| Published | 2026-07-20 |
| First published | 2024-02-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 29.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 155 |
| Author | Josep M Sobrepere |
| Maintainers | voliva, josepot |

## Links

- npm: https://www.npmjs.com/package/@polkadot-api/ws-provider
- Repository: https://github.com/polkadot-api/polkadot-api
- Homepage: https://github.com/polkadot-api/polkadot-api#readme
- Issues: https://github.com/polkadot-api/polkadot-api/issues
- npm.io page: https://npm.io/package/@polkadot-api/ws-provider

## Dependencies (3)

- [@polkadot-api/utils](https://npm.io/package/@polkadot-api/utils.md) 0.4.0
- [@polkadot-api/json-rpc-provider](https://npm.io/package/@polkadot-api/json-rpc-provider.md) 0.2.0
- [@polkadot-api/json-rpc-provider-proxy](https://npm.io/package/@polkadot-api/json-rpc-provider-proxy.md) 0.4.1

## Recent versions

- 0.9.1 (latest) — 2026-07-20
- 0.9.2-canary.786fa29 (canary) — 2026-09-01
- 0.9.0 (rc) — 2026-04-08
- 0.0.1-c9bb2ce3de90b7b5745189b6e3258c7cd945bb40.1.0 (next) — 2024-04-04
- 0.9.2-canary.2bce46a — 2026-08-20
- 0.9.2-canary.e24aebd — 2026-08-20
- 0.9.2-canary.d8b2d3d — 2026-08-18
- 0.9.2-canary.8c00f44 — 2026-08-17
- 0.9.2-canary.57eb571 — 2026-07-29
- 0.9.2-canary.996069a — 2026-07-29
- 0.9.2-canary.7f105ae — 2026-07-28
- 0.9.2-canary.9390531 — 2026-07-20
- 0.9.1-canary.22b1f2b — 2026-07-20
- 0.9.1-canary.fdb7fff — 2026-07-13
- 0.9.1-canary.d2a06c4 — 2026-07-10
- … 224 more at https://npm.io/package/@polkadot-api/ws-provider/versions

## README

# @polkadot-api/ws-provider

`JsonRpcProvider` to connect to a chain via a WebSocket.

```ts
function WebSocketProvider(
  uri: string,
  protocols?: string | string[],
): JsonRpcProvider
```

This package doesn't have any export on the root. Instead it has 2 subpaths, each for a different environment.

For web runtimes, where the browser's `WebSocket` constructor can be used, import `WebSocketProvider` from `@polkadot-api/ws-provider/web`.

For other runtimes where the `WebSocket` from the module `ws` should be used instead, import `WebSocketProvider` from `@polkadot-api/ws-provider/node`.

---
_Source: https://npm.io/package/@polkadot-api/ws-provider · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
