# @open-rpc/client-js

> A browser-compatible JSON-RPC client with multiple transports.

Latest version **2.1.0** (published 2026-08-14) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @open-rpc/client-js
pnpm add @open-rpc/client-js
yarn add @open-rpc/client-js
bun add @open-rpc/client-js
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2026-08-14 |
| First published | 2019-05-14 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 269.5 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 138 |
| Maintainers | belfordz, shanejonas, zcstarr |

## Links

- npm: https://www.npmjs.com/package/@open-rpc/client-js
- Repository: https://github.com/open-rpc/client-js
- Homepage: https://github.com/open-rpc/client-js#readme
- Issues: https://github.com/open-rpc/client-js/issues
- npm.io page: https://npm.io/package/@open-rpc/client-js

## Dependencies (3)

- [ws](https://npm.io/package/ws.md) 8.18.3
- [isomorphic-ws](https://npm.io/package/isomorphic-ws.md) 5.0.0
- [strict-event-emitter-types](https://npm.io/package/strict-event-emitter-types.md) 2.0.0

## Recent versions

- 2.1.0 (latest) — 2026-08-14
- 2.0.0 — 2025-10-29
- 1.8.1 — 2023-01-18
- 1.8.0 — 2023-01-04
- 1.7.1 — 2021-08-20
- 1.7.0 — 2021-05-28
- 1.6.3 — 2021-04-08
- 1.6.2 — 2020-12-17
- 1.6.1 — 2020-12-07
- 1.6.0 — 2020-10-19
- 1.5.2 — 2020-10-09
- 1.5.1 — 2020-09-25
- 1.5.0 — 2020-08-03
- 1.4.0 — 2020-07-27
- 1.3.3 — 2020-07-17
- … 14 more at https://npm.io/package/@open-rpc/client-js/versions

## README

# OpenRPC Client JS

<center>
  <span>
    <img alt="CircleCI branch" src="https://img.shields.io/circleci/project/github/open-rpc/client-js/master.svg">
    <img src="https://codecov.io/gh/open-rpc/client-js/branch/master/graph/badge.svg" />
    <img alt="Dependabot status" src="https://api.dependabot.com/badges/status?host=github&repo=open-rpc/client-js" />
    <img alt="Chat on Discord" src="https://img.shields.io/badge/chat-on%20discord-7289da.svg" />
    <img alt="npm" src="https://img.shields.io/npm/dt/@open-rpc/client-js.svg" />
    <img alt="GitHub release" src="https://img.shields.io/github/release/open-rpc/client-js.svg" />
    <img alt="GitHub commits since latest release" src="https://img.shields.io/github/commits-since/open-rpc/client-js/latest.svg" />
  </span>
</center>

A browser-compatible JSON-RPC client with multiple transports:

- EventEmitter
- HTTP/HTTPS
- WebSocket
- PostMessageWindow
- PostMessageIframe

```javascript
import { RequestManager, HTTPTransport, Client } from "@open-rpc/client-js";
const transport = new HTTPTransport("http://localhost:8545");
const client = new Client(new RequestManager([transport]));
const result = await client.request({ method: "addition", params: [2, 2] });
// => { jsonrpc: '2.0', id: 1, result: 4 }
```

#### Examples

<details>
  <summary>EventEmitter</summary>

```javascript
import { EventEmitter } from "events";
import {
  RequestManager,
  EventEmitterTransport,
  Client,
} from "@open-rpc/client-js";

const chan1 = "chan1";
const chan2 = "chan2";

const emitter = new EventEmitter();
const transport = new EventEmitterTransport(emitter, chan1, chan2);
const requestManager = new RequestManager([transport]);
const client = new Client(requestManager);

// event emitter server code
emitter.on(chan1, (jsonrpcRequest) => {
  const res = {
    jsonrpc: "2.0",
    result: "potato",
    id: jsonrpcRequest.id,
  };
  emitter.emit(chan2, JSON.stringify(res));
});

const main = async () => {
  const result = await client.request({ method: "addition", params: [2, 2] });
  console.log(result);
};

main().then(() => {
  console.log("DONE");
});
```

</details>

<details>
  <summary>HTTP</summary>

```javascript
import { RequestManager, Client, HTTPTransport } from "@open-rpc/client-js";

const transport = new HTTPTransport("http://localhost:3333");
const requestManager = new RequestManager([transport]);
const client = new Client(requestManager);

const main = async () => {
  const result = await client.request({ method: "addition", params: [2, 2] });
  console.log(result);
};

main().then(() => {
  console.log("DONE");
});
```

</details>

<details>
  <summary>WebSocket</summary>

```javascript
import {
  RequestManager,
  Client,
  WebSocketTransport,
} from "@open-rpc/client-js";

const transport = new WebSocketTransport("ws://localhost:3333");
const requestManager = new RequestManager([transport]);
const client = new Client(requestManager);

const main = async () => {
  const result = await client.request({ method: "addition", params: [2, 2] });
  console.log(result);
};

main().then(() => {
  console.log("DONE");
  client.close();
});
```

</details>

### Building

```sh
# Install bun
curl -fsSL https://bun.sh/install | bash

# Build the repo
bun install
bun run build
```

### Contributing

How to contribute, build and release are outlined in [CONTRIBUTING.md](CONTRIBUTING.md), [BUILDING.md](BUILDING.md) and [RELEASING.md](RELEASING.md) respectively. Commits in this repository follow the [CONVENTIONAL_COMMITS.md](CONVENTIONAL_COMMITS.md) specification.

---
_Source: https://npm.io/package/@open-rpc/client-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
