# react-stomp

> React websocket component with STOMP over SockJS

Latest version **5.1.0** (published 2021-01-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-stomp
pnpm add react-stomp
yarn add react-stomp
bun add react-stomp
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.1.0 |
| Published | 2021-01-16 |
| First published | 2017-12-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 23.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 133 |
| Author | lahsivjar |
| Maintainers | lahsivjar |
| Keywords | react, websocket, sockjs, stomp |

## Links

- npm: https://www.npmjs.com/package/react-stomp
- Repository: https://github.com/lahsivjar/react-stomp
- Homepage: https://github.com/lahsivjar/react-stomp#readme
- Issues: https://github.com/lahsivjar/react-stomp/issues
- npm.io page: https://npm.io/package/react-stomp

## Dependencies (4)

- [net](https://npm.io/package/net.md) ^1.0.2
- [stompjs](https://npm.io/package/stompjs.md) ^2.3.3
- [handlebars](https://npm.io/package/handlebars.md) ^4.7.6
- [sockjs-client](https://npm.io/package/sockjs-client.md) ^1.5.0

## 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

- 5.1.0 (latest) — 2021-01-16
- 5.0.0 — 2020-03-04
- 4.3.0 — 2019-12-30
- 4.2.0 — 2019-09-19
- 4.1.1 — 2019-06-06
- 4.1.0 — 2019-01-17
- 4.0.0 — 2018-09-20
- 3.3.0 — 2018-07-17
- 3.2.0 — 2018-05-08
- 3.1.0 — 2018-05-08
- 3.0.1 — 2018-02-14
- 3.0.0 — 2018-02-11
- 2.1.1 — 2018-01-04
- 2.1.0 — 2018-01-04
- 2.0.0 — 2017-12-20
- … 7 more at https://npm.io/package/react-stomp/versions

## README

# react-stomp

[![Build Status](https://travis-ci.com/lahsivjar/react-stomp.svg?branch=master)](https://travis-ci.com/lahsivjar/react-stomp?branch=master) [![Coverage Status](https://coveralls.io/repos/github/lahsivjar/react-stomp/badge.svg?branch=master)](https://coveralls.io/github/lahsivjar/react-stomp?branch=master) [![License](https://img.shields.io/npm/l/react-stomp.svg)](https://github.com/lahsivjar/react-stomp/blob/master/LICENSE)  [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/standard/standard)

React component for [SockJS-client](https://github.com/sockjs/sockjs-client) with [STOMP](https://stomp.github.io/) messaging protocol.

## Installation

```sh
npm install --save react-stomp
```

## Example Usage

```jsx
import React from 'react';
import SockJsClient from 'react-stomp';

class SampleComponent extends React.Component {
  constructor(props) {
    super(props);
  }

  sendMessage = (msg) => {
    this.clientRef.sendMessage('/topics/all', msg);
  }

  render() {
    return (
      <div>
        <SockJsClient url='http://localhost:8080/ws' topics={['/topics/all']}
            onMessage={(msg) => { console.log(msg); }}
            ref={ (client) => { this.clientRef = client }} />
      </div>
    );
  }
}
```

## Demonstration

<https://react-websocket.herokuapp.com/index>

A working implementation using [Spring Boot](https://projects.spring.io/spring-boot/) and [react-talk](https://github.com/lahsivjar/react-talk) can be found at <https://github.com/lahsivjar/spring-websocket-template/tree/master/with-sockjs>

## API Docs

Auto generated docs available [here](API.md).

## Issues

Report any issues or bugs to <https://github.com/lahsivjar/react-stomp/issues>

## Changelog

### 5.1.0
- Fix subscribeHeaders corruption when subscribing to multiple topics
- Minor upgrades:
    - sinon
    - nyc
    - acorn
    - websocket-extensions
    - handlebars
    - lodash
    - sockjs-client
    - highlightjs
    - ini

### 5.0.0
- Update react from 16.6.3 to 16.13.0
- Fix deprecation of `componentWillReceiveProps`

### 4.3.0
- Update handlebar dependency

### 4.2.0

- Add `onConnectFailure` callback
- Upgrade babel to babel7

### 4.1.1

- [BugFix #96] Remove array slice of subscribe headers

### 4.1.0

- Update react from 16.5.0 to 16.6.3
- Update react-dom from 16.5.0 to 16.6.3
- [PR #93] Use STOMP message frame to find correct topic

### 4.0.0

-   Improve test coverage
-   [BugFix #61] Add support for receiving plain text messages
-   [BugFix #70] Fix reconnect loop under certain circumstances even after disconnect is called

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

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