Socket
Socket
Sign inDemoInstall

socket.io-client

Package Overview
Dependencies
11
Maintainers
2
Versions
127
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    socket.io-client

Realtime application framework client


Version published
Weekly downloads
4.2M
increased by1.26%
Maintainers
2
Install size
1.86 MB
Created
Weekly downloads
 

Package description

What is socket.io-client?

The socket.io-client npm package is a client-side library that enables real-time, bidirectional and event-based communication between web clients and servers. It works on every platform, browser or device, focusing equally on reliability and speed.

What are socket.io-client's main functionalities?

Connecting to a server

This code sample demonstrates how to connect to a Socket.IO server running on localhost at port 3000.

const io = require('socket.io-client');
const socket = io('http://localhost:3000');

Emitting events

This code sample shows how to emit an event to the server with an event name and associated data.

socket.emit('event_name', { some: 'data' });

Listening for events

This code sample illustrates how to listen for events emitted by the server and handle them with a callback function.

socket.on('event_name', function(data) {
  console.log(data);
});

Disconnecting from the server

This code sample shows how to handle a disconnection event when the client gets disconnected from the server.

socket.on('disconnect', function() {
  console.log('Disconnected from server');
});

Other packages similar to socket.io-client

Changelog

Source

4.5.1 (2022-05-17)

There were some minor bug fixes on the server side, which mandate a client bump.

Dependencies

Readme

Source

socket.io-client

Build Status NPM version Downloads

Sauce Test Status

Documentation

Please see the documentation here.

The source code of the website can be found here. Contributions are welcome!

Debug / logging

In order to see all the client debug output, run the following command on the browser console – including the desired scope – and reload your app page:

localStorage.debug = '*';

And then, filter by the scopes you're interested in. See also: https://socket.io/docs/v4/logging-and-debugging/

License

MIT

Keywords

FAQs

Last updated on 17 May 2022

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc