# A First WebSocket Connection

The ws package puts a WebSocketServer on the same server and port as an Express app, its connection, message and close events let the server hear from each client and answer it, and the browser's own WebSocket connects a page, with JSON messages whose type says what each one is.

![Cheat sheet: A First WebSocket Connection](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/e18fe3c12e5a4cc08eb5b7a7c282aec0.webp)

- Category: Node.js
- Level: Journeyman
- Tags: Event Listener, JSON.parse(), nodejs, Static Files in Express, web-development, WebSocket (web-development), ws
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/node-websockets-first-connection-cheat-sheet
