# Is socket.io-client ESM-only? Can you require() it?

> socket.io-client@4.8.3 ships CommonJS and ESM builds. Dual package — require() works on every Node.js version we test; import works too.

Realtime application framework client

Last verified Sep 9, 2026 against socket.io-client@4.8.3.

socket.io-client publishes both a CommonJS entry and a native ESM entry (ESM added in 3.0.0). require("socket.io-client") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=10.0.0. import "socket.io-client" works alongside it.

## What to do

1. Nothing to change. require("socket.io-client") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=10.0.0. import * as socketIoClient from "socket.io-client" works alongside it; use named imports for what the ESM entry exports.
2. TypeScript: types are bundled; install nothing extra.

## Facts

- Latest: 4.8.3 (Dec 23, 2025)
- Module format: Dual (CommonJS + ESM)
- Last CommonJS version: 4.8.3
- Native ESM since: 3.0.0
- TypeScript types: bundled
- Node engines: >=10.0.0
- Weekly downloads: 12.7M
- License: MIT

## Runtime test results for socket.io-client@4.8.3

Installed and executed on Sep 9, 2026 with require("socket.io-client") from a CommonJS file and import "socket.io-client" from an ES module.

| Runtime | require("socket.io-client") | import "socket.io-client" |
|---|---|---|
| Node.js 18 | works | works |
| Node.js 20 | works | works |
| Node.js 22 | works | works |
| Node.js 24 | works | works |
| Node.js 26 | works | works |
| Bun 1.4.0 | works | works |

## How to import socket.io-client

ES modules:

```js
import * as socketIoClient from "socket.io-client";
```

Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.

CommonJS:

```js
const socketIoClient = require("socket.io-client");
```

## Module format by version

Derived from the type, main and exports fields of every stable release on npm (119 versions; the newest 60 shown).

| Versions | Format | First published |
|---|---|---|
| 3.0.0 – 4.8.3 | Dual (CommonJS + ESM) | Nov 5, 2020 |
| 1.5.1 – 2.5.0 | CommonJS | Oct 24, 2016 |

## Frequently asked

**Is socket.io-client ESM-only?**

socket.io-client@4.8.3 ships CommonJS and ESM builds. socket.io-client publishes both a CommonJS entry and a native ESM entry (ESM added in 3.0.0). require("socket.io-client") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=10.0.0. import "socket.io-client" works alongside it.

**Can I require socket.io-client?**

Yes. socket.io-client ships a CommonJS entry alongside the native ESM entry. require("socket.io-client") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=10.0.0.

**Does socket.io-client work in Bun?**

Yes. import "socket.io-client" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

**Does socket.io-client ship TypeScript types?**

Yes. socket.io-client bundles its own type declarations; no @types package is needed.

## Links

- [socket.io-client on npm](https://www.npmjs.com/package/socket.io-client)
- [Source repository](https://github.com/socketio/socket.io)
- [HTML version](https://canirequire.com/package/socket.io-client/)
- [JSON version](https://canirequire.com/package/socket.io-client.json)

---

For scripts and AI agents: any package is at https://canirequire.com/package/<name>/index.md (Markdown) or https://canirequire.com/package/<name>.json (JSON); the site index is https://canirequire.com/llms.txt. Fetch the URL directly; no search needed.
