A promise-based WebSocket implementation for Node.js, version 1.0.0-1. Built on top of the popular ws library, it provides promise-returning methods for common WebSocket operations such as send, ping, and pong, as well as factory methods for creating client and server instances. This package offers a cleaner async/await style compared to ws, which uses callbacks and events. It is maintained as a thin wrapper, inheriting the full ws API while adding promise support. Equivalent to using ws with promisify or wrapping manually, but integrated directly.
npm install promise-wsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows both a client and server WebSocket using promise-ws. Client connects, sends a message, and logs response. Server listens on port 8080 and echoes a welcome message. Demonstrates async/await usage and promise-returning methods.
Monitor for stable release; pin exact version in production.
Use await WebSocket.create(url) for client and await WebSocket.Server.create(options) for server.
For reliable delivery, listen to the 'error' event and consider using the callback version from ws directly if needed.
Install @types/ws and import ws types separately, or augment the module.
Use import syntax or configure your bundler/transpiler to handle ESM.
Replace new WebSocket(url) with await WebSocket.create(url)
Run npm install promise-ws and ensure import 'promise-ws' is correct (no subpath)
Use await WebSocket.Server.create(options) to get a server instance