npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@stomp/stompjs

v7.5.0

Published

STOMP client for Javascript and Typescript

Readme

STOMP.js

Build Status - Firefox, Chrome Build Status - Safari, Edge Node.js Tests API Docs Refresh

STOMP.js is a fully-fledged STOMP over WebSocket library for browsers and Node.js, providing seamless integration with STOMP protocol-compliant messaging brokers.

Table of Contents

Introduction

This library enables clients to connect to configured STOMP-over-WebSocket broker endpoints. It supports the STOMP protocol specifications v1.0, v1.1, and v1.2; a broker supporting STOMP over TCP alone is not sufficient for a direct WebSocket connection.

Popular brokers like RabbitMQ and ActiveMQ can provide STOMP-over-WebSocket endpoints with the appropriate configuration. For RabbitMQ, enable the rabbitmq_web_stomp plugin. Node.js clients can use STOMP over TCP through the separate tcp-wrapper adapter.

Features

  • Simple and intuitive API for interacting with the STOMP protocol
  • Support for STOMP protocol versions: 1.2, 1.1, and 1.0
  • Optional SockJS integration through webSocketFactory (requires a separate SockJS client and a compatible server endpoint; fallback is not supplied automatically)
  • Supports both browser and Node.js environments
  • STOMP over TCP in Node.js through tcp-wrapper (separate adapter)
  • Automatic reconnection with configurable delays
  • Configurable incoming and outgoing STOMP heartbeats
  • Full support for binary payloads
  • RxJS integration through rx-stomp for reactive programming

Getting Started

This section provides a quick guide to integrating STOMP.js into your browser or Node.js application.

Both examples assume a local RabbitMQ broker with the rabbitmq_web_stomp plugin enabled and a WebSocket endpoint at ws://localhost:15674/ws (see the RabbitMQ Dockerfile). The /topic/test01 destination follows RabbitMQ's STOMP conventions; adapt the endpoint, destinations, and connectHeaders for your broker. The guest/guest credentials are for local development only, and RabbitMQ restricts guest access to loopback by default. Use a configured account with appropriate permissions in production. For HTTPS pages, use a TLS-enabled wss:// endpoint instead of ws://.

Browser

To use STOMP.js in a browser:

  1. Add the following in your HTML file:

    <script type="importmap">
      {
        "imports": {
          "@stomp/stompjs": "https://ga.jspm.io/npm:@stomp/[email protected]/esm6/index.js"
        }
      }
    </script>

    Modern browsers support import maps natively; no shim is needed. For older browsers without import-map support, use a compatible version of es-module-shims following its setup instructions.

  2. Add this module script after the import map:

    <script type="module">
      import { Client } from '@stomp/stompjs';
    
      const client = new Client({
        brokerURL: 'ws://localhost:15674/ws',
        connectHeaders: { login: 'guest', passcode: 'guest' },
        onConnect: () => {
          client.subscribe('/topic/test01', message =>
            console.log(`Received: ${message.body}`),
          );
          client.publish({
            destination: '/topic/test01',
            body: 'First Message',
          });
        },
        onStompError: frame => {
          console.error('Broker error:', frame.headers['message'], frame.body);
        },
        onWebSocketError: event => {
          console.error('WebSocket error:', event);
        },
      });
    
      client.activate();
    
      // When finished, call this from your application's cleanup logic:
      // await client.deactivate();
    </script>

Node.js

To use STOMP.js in a Node.js environment:

  1. Install the package:

    npm install @stomp/stompjs ws
  2. Save this as example.mjs and run node example.mjs (or use a .js file in a package with "type": "module"):

    import { Client } from '@stomp/stompjs';
    
    import { WebSocket } from 'ws';
    globalThis.WebSocket = WebSocket;
    
    const client = new Client({
      brokerURL: 'ws://localhost:15674/ws',
      connectHeaders: { login: 'guest', passcode: 'guest' },
      onConnect: () => {
        client.subscribe('/topic/test01', message =>
          console.log(`Received: ${message.body}`),
        );
        client.publish({ destination: '/topic/test01', body: 'First Message' });
      },
      onStompError: frame => {
        console.error('Broker error:', frame.headers['message'], frame.body);
      },
      onWebSocketError: event => {
        console.error('WebSocket error:', event);
      },
    });
    
    client.activate();
    
    // When finished, call this from your application's cleanup logic:
    // await client.deactivate();

Keep subscriptions inside onConnect so they are recreated after automatic reconnection. When your application no longer needs the connection, run await client.deactivate() in the same scope as client to disconnect and stop reconnection attempts.


Documentation

Comprehensive documentation can be found at: STOMP.js Documentation

Upgrading

If you are updating from an older version of STOMP.js, review the Upgrading Guide for any required changes.

Usage with RxJS

Rx-Stomp builds upon this library, exposing all its features as RxJS Observables, enabling reactive programming patterns.

TypeScript Support

STOMP.js includes built-in TypeScript definitions, eliminating the need for external type definition files. Begin coding with TypeScript out-of-the-box!

Changelog

Visit the Change Log for information about changes, improvements, and fixes in recent releases.

Contributing

Thinking of contributing to STOMP.js? Great! To get started:

  • Read the Contributing Guide for development instructions.
  • Report bugs or suggest features by creating an issue on GitHub.

We welcome contributions from the community!

Authors

This library is made possible by these amazing contributors:

This library is originally based on stompjs by Jeff Mesnil with enhancements and bug fixes from Jeff Lindsay and Vanessa Williams.

License

Licensed under the Apache-2.0 License. See the LICENSE file for details.