Ir para o conteúdo principal
Version: 4.x

Client Installation

Version compatibility

Here is the compatibility table between the server and the JS client:

JS Client versionSocket.IO server version

[1] Yes, with allowEIO3: true

Please check the associated migration guides:

Browser support

Socket.IO does support IE9 and above. IE 6/7/8 are not supported anymore.

Browser compatibility is tested thanks to the awesome Sauce Labs platform:

Browser support

Latest releases


Standalone build

By default, the Socket.IO server exposes a client bundle at /

io will be registered as a global variable:

<script src="/"></script>
const socket = io();

If you don't need this (see other options below), you can disable the functionality on the server side:

const { Server } = require("");

const io = new Server({
serveClient: false

From a CDN

You can also include the client bundle from a CDN:

<script src="" integrity="sha384-2huaZvOR9iDzHqslqwpR87isEmrfxqyWOF7hr7BY6KG0+hVKLoEXMPUJw3ynWuhO" crossorigin="anonymous"></script>

Socket.IO is also available from other CDN:

There are several bundles available:

NameSizeDescription kB gzipUnminified version, with debug kB min+gzipProduction version, without debug kB min+gzipProduction version, without debug and with the msgpack parser

The debug package allows to print debug information to the console. You can find more information here.

During development, we recommend using the bundle. By setting localStorage.debug = '', any event received by the client will be printed to the console.

For production, please use the bundle, which is an optimized build excluding the debug package.

From NPM

The Socket.IO client is compatible with bundlers like webpack or browserify.

npm install

The client can also be run from Node.js.

Note: for the reasons cited above, you may want to exclude debug from your browser bundle. With webpack, you can use webpack-remove-debug.

Note for TypeScript users: the types are now included in the package and thus the types from @types/ are not needed anymore and may in fact cause errors:

Object literal may only specify known properties, and 'extraHeaders' does not exist in type 'ConnectOpts'


Dependency tree

A basic installation of the client includes 15 packages:

├── backo2@1.0.2
├─┬ debug@4.3.3
│ └── ms@2.1.2
│ ├── deduped
│ ├── debug@4.3.3 deduped
│ ├─┬
│ │ └── base64-arraybuffer@1.0.1
│ ├── has-cors@1.1.0
│ ├── parseqs@0.0.6
│ ├── parseuri@0.0.6 deduped
│ ├─┬ ws@8.2.3
│ │ ├── UNMET OPTIONAL DEPENDENCY bufferutil@^4.0.1
│ │ └── UNMET OPTIONAL DEPENDENCY utf-8-validate@^5.0.2
│ ├── xmlhttprequest-ssl@2.0.0
│ └── yeast@0.1.2
├── parseuri@0.0.6
├── deduped
└── debug@4.3.3 deduped

Transitive versions

The package brings the engine that is responsible for managing the low-level connections (HTTP long-polling or WebSocket). See also: How it works versionws version1

[1] for Node.js users only. In the browser, the native WebSocket API is used.