# universal-websocket-client

> Use the same WebSocket client code in a browser or Node.js for isomorphic apps

Latest version **1.0.3** (published 2025-02-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install universal-websocket-client
pnpm add universal-websocket-client
yarn add universal-websocket-client
bun add universal-websocket-client
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2025-02-18 |
| First published | 2017-03-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | Gabriel Grant |
| Maintainers | gabrielgrant |
| Keywords | websocket, client, browser, node, isomorphic, universal |

## Links

- npm: https://www.npmjs.com/package/universal-websocket-client
- Repository: https://github.com/gabrielgrant/javascript-universal-websocket-client
- Homepage: https://github.com/gabrielgrant/javascript-universal-websocket-client#readme
- Issues: https://github.com/gabrielgrant/javascript-universal-websocket-client/issues
- npm.io page: https://npm.io/package/universal-websocket-client

## Dependencies (1)

- [ws](https://npm.io/package/ws.md) ^8.18.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2025-02-18
- 1.0.2 — 2018-06-05
- 1.0.1 — 2017-03-02
- 1.0.0 — 2017-03-02

## README

Uses the native WebSocket client code in a browser and the [ws package client](https://www.npmjs.com/package/ws) on Node.js, enabling isomorphic applications to use WebSockets. Keeps your browser build slim, by not including any of the Node WebSocket implementation.


Installation 
============

```
npm install --save universal-websocket-client
```

Usage
=====

```
var WebSocket = require('universal-websocket-client');

\\ ... use the [WebSocket client interface](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket).
```

On the client side, you'll now need to use [browserify](http://browserify.org/) (or Webpack or something similar) to bundle your code.

See [`tests/browser`](tests/browser) and [`tests/node`](tests/node)


Run Tests
=========

These are end-to-end tests, that test the installed the package.

Node
----

```
cd tests/browser/
npm install
npm test
```

Browser
-------

```
cd tests/node/
npm install
npm test
```

Then visit [`http://localhost:8000`](http://localhost:8000)

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