# @xmpp/stream-management

> XMPP stream management for JavaScript

Latest version **0.14.0** (published 2025-10-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install @xmpp/stream-management
pnpm add @xmpp/stream-management
yarn add @xmpp/stream-management
bun add @xmpp/stream-management
```

## Health

**Score 58/100 (C)** — status: stable.

Positive: has types package; esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.14.0 |
| Published | 2025-10-29 |
| First published | 2020-02-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/xmpp__stream-management) |
| Module format | ESM + CommonJS |
| Node | >= 20.10 |
| Dependencies | 4 |
| Unpacked size | 27.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2275 |
| Maintainers | sonny |
| Keywords | XMPP, stream, management |

## Links

- npm: https://www.npmjs.com/package/@xmpp/stream-management
- Repository: https://github.com/xmppjs/xmpp.js
- Homepage: https://github.com/xmppjs/xmpp.js/tree/main/packages/stream-management
- Issues: http://github.com/xmppjs/xmpp.js/issues
- npm.io page: https://npm.io/package/@xmpp/stream-management

## Dependencies (4)

- [@xmpp/xml](https://npm.io/package/@xmpp/xml.md) ^0.14.0
- [@xmpp/time](https://npm.io/package/@xmpp/time.md) ^0.14.0
- [@xmpp/error](https://npm.io/package/@xmpp/error.md) ^0.14.0
- [@xmpp/events](https://npm.io/package/@xmpp/events.md) ^0.14.0

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 0.14.0 (latest) — 2025-10-29
- 0.13.3 — 2024-12-23
- 0.13.1 — 2022-02-16
- 0.13.0 — 2021-08-28
- 0.12.1 — 2021-08-22
- 0.12.0 — 2020-12-21
- 0.11.1 — 2020-02-15
- 0.11.0 — 2020-02-14
- 0.10.0 — 2020-02-07

## README

# stream-management

[Stream Management](https://xmpp.org/extensions/xep-0198.html) for `@xmpp/client`.

Included and enabled in `@xmpp/client`.

Supports Node.js and browsers.

When the session is resumed the `online` event is not emitted as session resumption is transparent.
However `entity.status` is set to `online`.
If the session fails to resume, entity will fallback to regular session establishment in which case `online` event will be emitted.

- Automatically responds to acks.
- Periodically request acks.
- If server fails to respond, triggers a reconnect.
- On reconnect retry sending the queue

When a stanza is re-sent, a [delay element](https://xmpp.org/extensions/xep-0203.html) will be added to it.

- `from` client jid
- `stamp` [date/time](https://xmpp.org/extensions/xep-0082.html) at which the stanza was meant to be sent

```xml
<delay xmlns="urn:xmpp:delay"
  from="username@example.net/resource"
  stamp="1990-01-01T00:00:00Z"
/>
```

## Events

### resumed

Indicates that the connection was resumed. When that happens the `online` event is not emitted but `xmpp.status` will be `online`.

```js
const xmpp = client(...);
const {streamManagement} = xmpp;

streamManagement.on('resumed', () => {
  console.log("session resumed");
});
```

### fail

Indicates that a stanza failed to send to the server and will not be retried.

```js
const xmpp = client(...);
const {streamManagement} = xmpp;

streamManagement.on('fail', (stanza) => {
  console.log("fail to send", stanza.toString());
});
```

### ack

Indicates that a stanza has been acknowledged by the server.

```js
const xmpp = client(...);
const {streamManagement} = xmpp;

streamManagement.on('ack', (stanza) => {
  console.log("stanza acknowledge by the server", stanza.toString());
});
```

## References

[XEP-0198: Stream Management](https://xmpp.org/extensions/xep-0198.html#inline-enable)

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