# react-webrtc

> WebRTC React mixins for real-time communication in React components

Latest version **1.0.0** (published 2015-02-19) · MIT license · 0 weekly downloads

## Install

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

## 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 | 1.0.0 |
| Published | 2015-02-19 |
| First published | 2015-02-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 84 |
| Author | Roman Liutikov |
| Maintainers | roman01la |
| Keywords | react-component, react, reactjs, webrtc |

## Links

- npm: https://www.npmjs.com/package/react-webrtc
- Repository: https://github.com/roman01la/react-webrtc
- Issues: https://github.com/roman01la/react-webrtc/issues
- npm.io page: https://npm.io/package/react-webrtc

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2015-02-19

## README

# React WebRTC

WebRTC React mixins for real-time communication in React components using [PeerJS](https://github.com/peers/peerjs) library. Read more on how [PeerJS](http://peerjs.com/docs) works.

## WIP

This is WIP, check [Todo](#todo). More features will come soon.

## Installation

This package requires `webpack` and [`babel-loader`](https://github.com/babel/babel-loader). Check [`webpack.config.js`](./webpack.config.js) for build configuration.

`npm install react-webrtc`

## Mixins

### DataChannelMixin (P2P data transmission)

This mixin extends React component with API call functions and event handling interface.

Also component's state will be populated with `rtc_id` property, which is a session ID for current peer.

#### API

- `.connect(id)` — connect to remote peer by its `id`.
- `.send(data)` — send data to all connected peers.
- `.close(id)` — close all connections or specified by `id`.

#### Interface

- `._onData (data) {...}` — handle incoming data.
- `._onInbound (id) {...}` — handle inbound connection.
- `._onInboundClose (id) {...}` — handle closed inbound connection.
- `._onOutbound (id) {...}` — handle outbound connection.
- `._onOutboundClose (id) {...}` — handle closed outbound connection.

## Usage

Check [`examples`](https://github.com/roman01la/react-webrtc/blob/master/examples/) directory.

## Development

`npm install && npm start`

Go to [localhost:3000/examples/](http://localhost:3000/examples/)

## Todo

- [x] DataChannel
- [ ] MediaStream

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