Socket
Socket
Sign inDemoInstall

socket.io-client

Package Overview
Dependencies
Maintainers
1
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

socket.io-client

Socket.IO client for the browser and node.js


Version published
Maintainers
1
Created

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

Keywords

FAQs

Package last updated on 27 Oct 2011

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc