# ws

*noun*

say it: **“DUB-ul-yoo ES”** **/ˈdʌbəlju ˈɛs/**

A popular npm package for WebSocket servers and clients in Node.

## What is the **ws** package?

**ws** is the npm package most Node projects use for WebSockets. Its `WebSocketServer` accepts connections, and each connection's `send` method and `"message"` event pass messages both ways.

```javascript
import { WebSocketServer } from "ws";

const wss = new WebSocketServer({ port: 8080 });
wss.on("connection", (socket) => {
  socket.send("Welcome to the match!");
  socket.on("message", (text) => console.log(`Fan says: ${text}`));
});
```

## In a sentence

- “With **ws**, a WebSocket server on port 8080 takes about five lines.”
- “The scoreboard server uses **ws** to keep a connection open to every fan's browser.”

Level: Journeyman · [More Node.js terms at this level](https://www.ask-codey.com/glossary?category=nodejs&level=3)

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/ws
