# @xmpp/jid

> XMPP identifiers (JID) for JavaScript

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

## Install

```sh
npm install @xmpp/jid
pnpm add @xmpp/jid
yarn add @xmpp/jid
bun add @xmpp/jid
```

## 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 | 2016-10-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/xmpp__jid) |
| Module format | ESM + CommonJS |
| Node | >= 20.10 |
| Dependencies | 0 |
| Unpacked size | 20 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2275 |
| Maintainers | sonny |
| Keywords | XMPP, JID |

## Links

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

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.14.0 (latest) — 2025-10-29
- 0.13.2 — 2024-12-23
- 0.13.1 — 2022-02-13
- 0.13.0 — 2021-08-28
- 0.12.1 — 2021-08-22
- 0.12.0 — 2020-12-21
- 0.11.0 — 2020-02-14
- 0.10.0 — 2020-02-07
- 0.9.2 — 2020-01-02
- 0.9.0 — 2019-11-19
- 0.8.0 — 2019-10-06
- 0.7.4 — 2019-06-15
- 0.7.0 — 2019-02-03
- 0.6.0 — 2018-11-24
- 0.5.0 — 2018-10-07
- … 5 more at https://npm.io/package/@xmpp/jid/versions

## README

# JID

XMPP identifiers (JID) for JavaScript

| JID type | local |  @  |     domain     |  /  |  resource  |         usage          |
| :------: | :---: | :-: | :------------: | :-: | :--------: | :--------------------: |
|  domain  |       |     | wonderland.net |     |            | servers and components |
|   bare   | alice |  @  | wonderland.net |     |            |         users          |
|   full   | alice |  @  | wonderland.net |  /  | rabbithole | user resource (device) |

https://en.wikipedia.org/wiki/XMPP#Decentralization_and_addressing

## Install

`npm install @xmpp/jid`

## Usage

```js
import jid from "@xmpp/jid";

/*
 * All return an instance of jid.JID
 */
const addr = jid("alice@wonderland.net/rabbithole");
const addr = jid("alice", "wonderland.net", "rabbithole");

addr instanceof jid.JID; // true

// domain JIDs are created passing the domain as the first argument
const addr = jid("wonderland.net");

/*
 * local
 */
addr.local = "alice";
addr.local; // alice
// same as
addr.setLocal("alice");
addr.getLocal(); // alice

/*
 * domain
 */
addr.domain = "wonderland.net";
addr.domain; // wonderland.net
// same as
addr.setDomain("wonderland.net");
addr.getDomain(); // wonderland.net

/*
 * resource
 */
addr.resource = "rabbithole";
addr.resource; // rabbithole
// same as
addr.setResource("rabbithole");
addr.getResource(); // rabbithole

addr.toString(); // alice@wonderland.net/rabbithole
addr.bare(); // returns a JID without resource

addr.equals(some_jid); // returns true if the two JIDs are equal, false otherwise
// same as
jid.equal(addr, some_jid);
```

## Escaping

The [XEP-0106](http://xmpp.org/extensions/xep-0106.html) defines a method to escape and unescape characters that aren't allowed in the local part of the JID. This library fully implement it.

```js
const addr = jid("contact@example.net", "xmpp.net");
addr.toString(); // contact\40example.net@xmpp.net
// for display purpose only
addr.toString(true); // contact@example.net@xmpp.net
```

For user input, use

```js
jid("contact@example.net", "xmpp.net");
// over
jid("contact@example.net@xmpp.net");
```

## References

- [RFC 7622 XMPP Address Format](https://tools.ietf.org/html/rfc7622) mostly implemented, l10n WIP
- [XEP-0106 JID Escaping](https://xmpp.org/extensions/xep-0106.html) implemented

### Deprecated

- [XEP-0029 Definition of Jabber Identifiers (JIDs)](https://xmpp.org/extensions/xep-0029.html) 2003
- [RFC 3920 XMPP addressing](https://tools.ietf.org/html/rfc3920#section-3) 2004
- [RFC 3920 XMPP Address Format](https://tools.ietf.org/html/rfc6122) 2011

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