New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

wscl

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wscl

Simple browser WebSocket wrapper with some extra features

latest
npmnpm
Version
2.3.1
Version published
Maintainers
1
Created
Source

wscl

NPM version

Simple WebSocket wrapper with some extra features:

  • auto reconnect with exponential backoff strategy
  • wait connection before sending messages
  • on() returns unsubscribe function
  • on('message') & on('error') callback called with data and error (not event)

Lib is tiny. Its size limited to 635 bytes (with all deps, minified and brotlied).

How to use

yarn add wscl
import {Client, events} from 'wscl'

const wsc = new Client({
  url: 'wss://echo.websocket.org',
})

wsc.on(events.Open, console.log)
wsc.on(events.Close, console.log)
wsc.on(events.Message, console.log) // will be called with data not event
wsc.on(events.Error, console.log) // will be called with error not event

// you can send message before connect
wsc.send("message")

await wsc.connect()
console.log(wsc.connected)

wsc.close("reason")

Keywords

websocket

FAQs

Package last updated on 25 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts