# @libp2p/webrtc-star

> libp2p WebRTC transport that includes a discovery mechanism provided by the signalling-star

Latest version **7.0.0** (published 2023-04-24) · Apache-2.0 OR MIT license · 0 weekly downloads

## Install

```sh
npm install @libp2p/webrtc-star
pnpm add @libp2p/webrtc-star
yarn add @libp2p/webrtc-star
bun add @libp2p/webrtc-star
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 7.0.0 |
| Published | 2023-04-24 |
| First published | 2022-02-03 |
| Weekly downloads | 0 |
| License | Apache-2.0 OR MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=16.0.0 |
| Dependencies | 18 |
| Unpacked size | 190.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 314 |
| Maintainers | jacobheun, npm-service-account-libp2p, alanshaw, vascosantos, achingbrain, daviddias |
| Keywords | IPFS, libp2p |

## Links

- npm: https://www.npmjs.com/package/@libp2p/webrtc-star
- Repository: https://github.com/libp2p/js-libp2p-webrtc-star
- Homepage: https://github.com/libp2p/js-libp2p-webrtc-star/tree/master/packages/webrtc-star-transport#readme
- Issues: https://github.com/libp2p/js-libp2p-webrtc-star/issues
- npm.io page: https://npm.io/package/@libp2p/webrtc-star

## Dependencies (18)

- [delay](https://npm.io/package/delay.md) ^5.0.0
- [p-defer](https://npm.io/package/p-defer.md) ^4.0.0
- [err-code](https://npm.io/package/err-code.md) ^3.0.1
- [uint8arrays](https://npm.io/package/uint8arrays.md) ^4.0.2
- [@libp2p/logger](https://npm.io/package/@libp2p/logger.md) ^2.0.0
- [@libp2p/peer-id](https://npm.io/package/@libp2p/peer-id.md) ^2.0.0
- [socket.io-client](https://npm.io/package/socket.io-client.md) ^4.1.2
- [iso-random-stream](https://npm.io/package/iso-random-stream.md) ^2.0.2
- [@libp2p/interfaces](https://npm.io/package/@libp2p/interfaces.md) ^3.0.2
- [abortable-iterator](https://npm.io/package/abortable-iterator.md) ^5.0.1
- [@libp2p/webrtc-peer](https://npm.io/package/@libp2p/webrtc-peer.md) ^2.0.0
- [@multiformats/mafmt](https://npm.io/package/@multiformats/mafmt.md) ^12.1.0
- [@multiformats/multiaddr](https://npm.io/package/@multiformats/multiaddr.md) ^12.1.2
- [@libp2p/interface-peer-id](https://npm.io/package/@libp2p/interface-peer-id.md) ^2.0.0
- [@libp2p/interface-transport](https://npm.io/package/@libp2p/interface-transport.md) ^4.0.0
- [@libp2p/interface-connection](https://npm.io/package/@libp2p/interface-connection.md) ^5.0.1
- [@libp2p/webrtc-star-protocol](https://npm.io/package/@libp2p/webrtc-star-protocol.md) ^4.0.0
- [@libp2p/interface-peer-discovery](https://npm.io/package/@libp2p/interface-peer-discovery.md) ^1.0.0

## Recent versions

- 7.0.0 (latest) — 2023-04-24
- 6.0.0 — 2023-01-06
- 5.0.3 — 2022-10-17
- 5.0.2 — 2022-10-13
- 5.0.1 — 2022-10-12
- 5.0.0 — 2022-10-12
- 4.0.1 — 2022-10-07
- 4.0.0 — 2022-10-07
- 3.0.3 — 2022-09-21
- 3.0.2 — 2022-09-21
- 3.0.1 — 2022-08-10
- 3.0.0 — 2022-06-17
- 2.0.1 — 2022-06-15
- 2.0.0 — 2022-06-15
- 1.0.12 — 2022-05-23
- … 13 more at https://npm.io/package/@libp2p/webrtc-star/versions

## README

# @libp2p/webrtc-star <!-- omit in toc -->

[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-webrtc-star.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-webrtc-star)
[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p-webrtc-star/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/libp2p/js-libp2p-webrtc-star/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)

> libp2p WebRTC transport that includes a discovery mechanism provided by the signalling-star

## Table of contents <!-- omit in toc -->

- [Install](#install)
  - [Browser `<script>` tag](#browser-script-tag)
- [Description](#description)
- [Usage](#usage)
  - [Using this module in Node.js (read: not in the browser)](#using-this-module-in-nodejs-read-not-in-the-browser)
  - [Using this module in the Browser](#using-this-module-in-the-browser)
- [Signalling server](#signalling-server)
- [API](#api)
  - [Transport](#transport)
  - [Connection](#connection)
  - [Peer Discovery - `ws.discovery`](#peer-discovery---wsdiscovery)
- [License](#license)
- [Contribution](#contribution)

## Install

```console
$ npm i @libp2p/webrtc-star
```

### Browser `<script>` tag

Loading this module through a script tag will make it's exports available as `Libp2pWebrtcStar` in the global namespace.

```html
<script src="https://unpkg.com/@libp2p/webrtc-star/dist/index.min.js"></script>
```

[![](https://raw.githubusercontent.com/libp2p/interface-transport/master/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/blob/master/packages/libp2p-interfaces/src/transport/README.md)
[![](https://raw.githubusercontent.com/libp2p/interface-connection/master/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/blob/master/packages/libp2p-interfaces/src/connection/README.md)
[![](https://raw.githubusercontent.com/libp2p/interface-peer-discovery/master/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/blob/master/packages/libp2p-interfaces/src/peer-discovery/README.md)

## Description

`libp2p-webrtc-star` is one of the WebRTC transports available for libp2p.

## Usage

### Using this module in Node.js (read: not in the browser)

To use this module in Node.js, you have to BYOI of WebRTC, there are multiple options out there, unfortunately, none of them are 100% solid. The ones we recommend are: [wrtc](http://npmjs.org/wrtc) and [electron-webrtc](https://www.npmjs.com/package/electron-webrtc).

Instead of just creating the WebRTCStar instance without arguments, you need to pass an options object with the WebRTC implementation:

```JavaScript
import { createLibp2pNode } from 'libp2p'
import { webRTCStar } from '@libp2p/webrtc-star'
import wrtc from 'wrtc'
import electronWebRTC from 'electron-webrtc'

// Using wrtc in node
const star = webRTCStar({ wrtc })

// Using electron-webrtc in electron
const star = webRTCStar({ wrtc: electronWebRTC() })

const node = await createLibp2pNode({
  addresses: {
    listen: [
      '/ip4/188.166.203.82/tcp/20000/wss/p2p-webrtc-star'
    ]
  },
  transports: [
    star.transport
  ],
  peerDiscovery: [
    star.discovery
  ]
})
await node.start()

await node.dial('/ip4/188.166.203.82/tcp/20000/wss/p2p-webrtc-star/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSooo2a')
```

### Using this module in the Browser

```JavaScript
import { createLibp2pNode } from 'libp2p'
import { webRTCStar } from '@libp2p/webrtc-star'

const star = webRTCStar()

const node = await createLibp2pNode({
  addresses: {
    listen: [
      '/ip4/188.166.203.82/tcp/20000/wss/p2p-webrtc-star'
    ]
  },
  transports: [
    star.transport
  ],
  peerDiscovery: [
    star.discovery
  ]
})
await node.start()

await node.dial('/ip4/188.166.203.82/tcp/20000/wss/p2p-webrtc-star/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSooo2a')
```

## Signalling server

This module has an accompanying signalling server which is used to discover other peers running the libp2p-webrtc-star transport.

Please see the [libp2p-webrtc-star-signalling-server](https://npmjs.com/package/libp2p-webrtc-star-signalling-server) module for more information.

## API

### Transport

[![](https://raw.githubusercontent.com/libp2p/interface-transport/master/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/blob/master/packages/libp2p-interfaces/src/transport/README.md)

### Connection

[![](https://raw.githubusercontent.com/libp2p/interface-connection/master/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/blob/master/packages/libp2p-interfaces/src/connection/README.md)

### Peer Discovery - `ws.discovery`

[![](https://raw.githubusercontent.com/libp2p/interface-peer-discovery/master/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/blob/master/packages/libp2p-interfaces/src/peer-discovery/README.md)

## License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

## Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

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