{"id":49740,"library":"websocket13","title":"websocket13","description":"A pure-JavaScript WebSocket protocol 13 (RFC 6455) implementation for Node.js with no native or heavy dependencies. Current stable version is 4.1.0, released with moderate cadence. It supports both client and server modes, requires Node.js >=12.22.0. Key differentiator: zero native dependencies, lightweight, and compatible with the standard WebSocket API subset. Not suitable for browsers (Node-only).","status":"active","version":"4.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/DoctorMcKay/node-websocket13","tags":["javascript","websocket","websockets","web socket","web sockets","networking","network","socket","sockets"],"install":[{"cmd":"npm install websocket13","lang":"bash","label":"npm"},{"cmd":"yarn add websocket13","lang":"bash","label":"yarn"},{"cmd":"pnpm add websocket13","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM import is recommended; CommonJS require works but may have issues with named exports in some bundlers.","wrong":"const WebSocket = require('websocket13').WebSocket","symbol":"WebSocket","correct":"import { WebSocket } from 'websocket13'"},{"note":"Named export; do not use default import.","wrong":"const WebSocketServer = require('websocket13').WebSocketServer","symbol":"WebSocketServer","correct":"import { WebSocketServer } from 'websocket13'"},{"note":"This is a named export, not default. Function returns a Duplex stream.","wrong":"import createWebSocketStream from 'websocket13'","symbol":"createWebSocketStream","correct":"import { createWebSocketStream } from 'websocket13'"}],"quickstart":{"code":"import { WebSocket } from 'websocket13';\nconst ws = new WebSocket('ws://localhost:8080', [], { timeout: 5000 });\nws.on('open', () => {\n  ws.send('Hello server!');\n});\nws.on('message', (data) => {\n  console.log('Received:', data.toString());\n  ws.close();\n});\nws.on('error', (err) => console.error('WebSocket error:', err));","lang":"typescript","description":"Creates a WebSocket client connection to a server, sends a message, logs received data, and closes."},"warnings":[{"fix":"Use syntax: new WebSocket(url, [], { headers: {...} })","message":"In v4, the 'WebSocket' constructor no longer accepts a third argument for protocols as array; now uses object options.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Check if data is Buffer or String and decode accordingly.","message":"The 'on('message')' callback now receives a Buffer instead of a String for binary messages in v4.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Replace 'WebSocketClient' with 'WebSocket'.","message":"The 'WebSocketClient' class alias is deprecated in v4, use 'WebSocket' directly.","severity":"deprecated","affected_versions":">=4.0.0"},{"fix":"Implement reconnection logic with exponential backoff.","message":"Automatic reconnection is not built-in; you must manually handle reconnection on 'close' event.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use 'ws' or native WebSocket for browser code.","message":"The library is Node-only and does not work in browser environments; it uses Node.js net and tls modules.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'12.22.0':38 '13':8 '4.1.0':24 '6455':10 'api':51 'browser':56 'cadenc':28 'client':32 'compat':46 'current':20 'depend':19,43 'differenti':40 'heavi':18 'implement':11 'javascript':5,60 'key':39 'lightweight':44 'mode':35 'moder':27 'nativ':16,42 'network':67,68 'node':58 'node-on':57 'node.js':13,37 'protocol':7 'pure':4 'pure-javascript':3 'releas':25 'requir':36 'rfc':9 'server':34 'socket':64,66,69,70 'stabl':21 'standard':49 'subset':52 'suitabl':54 'support':30 'version':22 'web':63,65 'websocket':6,50,61,62 'websocket13':1 'zero':41","created_at":"2026-06-07T17:03:21.843852+00:00","updated_at":"2026-06-07T17:03:21.843852+00:00","problems":[{"fix":"Use import { WebSocket } from 'websocket13'","cause":"Default import used when named export is required.","error":"TypeError: websocket13__WEBPACK_IMPORTED_MODULE_0__ is not a constructor"},{"fix":"Ensure WebSocket server is running and URL is correct (ws:// or wss://).","cause":"No server listening on the specified host:port or wrong URL.","error":"Error: connect ECONNREFUSED ::1:8080"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/DoctorMcKay/node-websocket13","github":"https://github.com/DoctorMcKay/node-websocket13","docs":null,"changelog":null,"pypi":null,"npm":"websocket13","openapi_spec":null,"status_page":null,"smithery":null,"categories":["networking","messaging"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}