Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 23, 2024 via pnpm

ws 8.16.0

Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js
Package summary
Share
0
issues
1
license
1
MIT
Package created
4 Dec 2011
Version published
26 Dec 2023
Maintainers
4
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
ws@8.16.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of ws 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does ws do?

The "ws" is a simple-to-use, supremely fast, and robustly tested WebSocket client and server implementation for Node.js. With "ws", you can effortlessly establish real-time, two-way channels of communication between the server and the client thereby making it a top choice for building real-time applications.

How do you use ws?

To start using the "ws" library, first install it using npm:

npm install ws

Then instantiate either the WebSocket client or the WebSocket server:

  • Client Example:
import WebSocket from 'ws';

const ws = new WebSocket('ws://www.host.com/path');

ws.on('open', function open() {
  ws.send('something'); // send a message
});

ws.on('message', function message(data) {
  console.log('received: %s', data); // print all received messages
});
  • Server Example:
import { WebSocketServer } from 'ws';

const wss = new WebSocketServer({ port: 8080 });

wss.on('connection', function connection(ws) {
  ws.on('message', function message(data) {
    console.log('received: %s', data); // print all received messages
  });

  ws.send('something'); // send a message
});

Please note, 'ws' does not work in a browser environment. To make the same code work seamlessly between Node.js and the browser, consider using a wrapper like isomorphic-ws.

Where are the ws docs?

The extensive documentation for the "ws" library can be found in the ws.md file in the docs folder of the project repository. The API Docs section provides a detailed explanation of all classes and utility functions provided by the "ws" library. The documentation is designed on the lines of Node.js documentation to make it easily comprehensible for developers familiar with Node.js.