# cometd

> Comet and WebSocket library for web messaging

Latest version **9.0.1** (published 2026-06-10) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install cometd
pnpm add cometd
yarn add cometd
bun add cometd
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 9.0.1 |
| Published | 2026-06-10 |
| First published | 2016-05-11 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 171.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Maintainers | sbordet |
| Keywords | comet, websocket, messaging, pubsub, publish, subscribe, rpc, p2p, peer-to-peer |

## Links

- npm: https://www.npmjs.com/package/cometd
- Repository: https://github.com/cometd/cometd-javascript
- Homepage: https://cometd.org
- Issues: https://bugs.cometd.org
- npm.io page: https://npm.io/package/cometd

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 9.0.1 (latest) — 2026-06-10
- 8.0.0-beta.3 (beta) — 2024-04-19
- 9.0.0 — 2025-10-10
- 8.0.11 — 2025-10-09
- 5.0.23 — 2025-08-19
- 7.0.19 — 2025-08-19
- 8.0.10 — 2025-08-15
- 7.0.18 — 2025-08-15
- 5.0.22 — 2025-08-14
- 8.0.9 — 2025-07-08
- 8.0.8 — 2025-05-13
- 8.0.7 — 2025-03-06
- 8.0.6 — 2024-10-01
- 8.0.5 — 2024-09-09
- 7.0.17 — 2024-09-09
- … 83 more at https://npm.io/package/cometd/versions

## README

## The CometD Project

Welcome to the [CometD](https://cometd.org) Project, a scalable comet 
(server push) and websocket messaging library for the web.

This repository mirrors the JavaScript sources hosted at the [main
CometD repository](https://github.com/cometd/cometd).
Those JavaScript sources are not suitable to be consumed with NPM,
and are therefore re-arranged in this repository for to make it simpler
to use CometD with NPM.

### Versions

* `8.0.x` &#8658; based on CometD 8.0.x - full ECMAScript 6 (modules, classes, `let`, `const`, arrow functions)
* `7.0.x` &#8658; based on CometD 7.0.x - minimal ECMAScript 6 (`let`, `const` and arrow functions)
* `6.0.x` &#8658; N/A
* `5.0.x` &#8658; based on CometD 5.0.x - minimal ECMAScript 5 (`var` everywhere)

Version `6.0.x` is not released to NPM since it's identical to `7.0.x`.  
The `6.0.x` numbering exists only because the main CometD project, on the server side, is different from `7.0.x`, but on the client side there is no difference.

### License

The CometD source code is released under the Apache 2.0 License.

### NPM Installation

```
npm install cometd
```

### ES6 Usage

```js
// Import the CometD symbols.
import {CometD} from "./cometd/cometd.js";
import {TimeStampExtension} from "./cometd/TimeStampExtension.js";

// Create the CometD object.
const cometd = new CometD();

// Optionally, register an extension.
cometd.registerExtension("timestamp", new TimeStampExtension());

// Configure the CometD object.
cometd.configure({
    url: "http://host/cometd"
});

// Handshake with the server.
cometd.handshake((reply) => {
    if (reply.successful) {
        // Subscribe to receive messages from the server.
        cometd.subscribe("/topic", (message) => {
            const dataFromServer = message.data;
            // Use dataFromServer.
        });
    }
});
```

---
_Source: https://npm.io/package/cometd · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
