Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

socket.io-client

Package Overview
Dependencies
Maintainers
2
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

socket.io-client

[![Build Status](https://github.com/socketio/socket.io-client/workflows/CI/badge.svg)](https://github.com/socketio/socket.io-client/actions) [![Dependency Status](https://david-dm.org/socketio/socket.io-client.svg)](https://david-dm.org/socketio/socket.io

  • 2.5.0
  • v2-latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.9M
decreased by-58.99%
Maintainers
2
Weekly downloads
 
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 26 Jun 2022

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