Registry / messaging / bare-ws

bare-ws

JSON →
library3.0.0jsnpmunverified

A lightweight WebSocket library for JavaScript environments, targeting Bare and Node.js. Version 3.0.0 provides both client and server WebSocket functionality with a simple stream-like API. It is actively maintained by Holepunch and offers TypeScript support. Compared to alternatives like ws, bare-ws is optimized for Bare runtime and has minimal dependencies.

messaging
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ESM default import is preferred, but CJS require also works.

import ws from 'bare-ws'

Named import works in both ESM and CJS.

import { Server } from 'bare-ws'

Named export exists; avoid destructuring from default export.

import { Socket } from 'bare-ws'

Creates a WebSocket server and client, sending and receiving messages.

import ws from 'bare-ws'; const server = new ws.Server({ port: 8080 }, (socket) => { socket.on('data', (data) => { console.log(data.toString()); }); }); server.on('listening', () => { const socket = new ws.Socket({ port: 8080 }); socket.write('Hello WebSocket'); });
Debug
Known footguns
breakingSocket constructor options differ from ws library.
gotchadata event returns Buffer, not string.
deprecatedThe 'close' event is deprecated, use 'end' instead.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
16 hits · last 30 days
gptbot
3
bytedance
3
bingbot
1
Resources