Modern XMPP in the browser, with a JSON API
Latest commit f508823 Jul 20, 2018

Modern XMPP in the browser, with a JSON API.

What is this? is a library for using modern XMPP in the browser, and it does that by exposing everything as JSON. Unless you insist, you have no need to ever see or touch any XML when using

Important Protocol Changes

Starting with v4.0.0, is using the protocol specified in RFC 7395 by default, which contains backwards incompatible changes.

Servers have started switching to using the RFC version of the WebSocket binding; notably, Prosody's WebSocket module for prosody-0.10. If your server has not yet been upgraded, you can set transports to ['old-websocket'] in the config:

var oldws = XMPP.createClient({
    transports: ['old-websocket']

Stanza Definitions Moved

As of v7.3.0, the XML/JSON mapping definitions have been split out into the jxt-xmpp module to allow their use outside of itself.


$ npm install

Building bundled/minified version (for AMD, etc)

First run npm install to get all of the dependencies, and then run make:

$ npm install
$ make

The bundled and minified files will be in the generated build directory.

Getting Started

  1. Find or install a server which supports XMPP over WebSocket (Prosody recommended).
  2. Run npm install in the node_modules/ directory.
  3. Run make to build build/stanzaio.bundle.js.
  4. Open demo.html in your browser.
  5. Enter your connection info, click connect.
  6. Use the JS console to play with the XMPP client (var client).

Echo Client Demo

var XMPP = require(''); // if using browserify

var client = XMPP.createClient({
    jid: '',
    password: 'hunter2',

    // If you have a .well-known/host-meta.json file for your
    // domain, the connection transport config can be skipped.

    transport: 'websocket',
    wsURL: 'wss://'
    // (or `boshURL` if using 'bosh' as the transport)

client.on('session:started', function () {

client.on('chat', function (msg) {
      to: msg.from,
      body: 'You sent: ' + msg.body





Created By

If you like this, follow @lancestout on twitter.