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

hello-webrtc

v0.0.3

Published

A simple js library to use WebRTC.

Downloads

10

Readme

Hello WebRTC

A simple js library to use WebRTC.

install

npm install --save hello-webrtc

usage

ES6:

import { WebRTCPeer, WebRTCClient } from 'hello-webrtc/src/hello-webrtc'

CommonJS:

const { WebRTCPeer, WebRTCClient } = require('hello-webrtc')

With Webpack:

import { WebRTCPeer, WebRTCClient } from 'hello-webrtc'

In browsers:

<script src="node_modules/hello-webrtc/dist/hello-webrtc.js"></script>
<script>
const { WebRTCPeer, WebRTCClient } = window.HelloWebRTC
</script>

To use:

let peer = new WebRTCPeer(options)
let client = new WebRTCClient(options)

WebRTCPeer

Methods

constructor(options)

options

  • stun: array of objects, required
  • turn: array of objects, required
  • websocket: an instance of WebSocket
  • user: which user do you want to connect to
  • room: in which room do you want to connect to the user
  • immediate: do you want to run setup() immediately, default is true
let peer = new WebRTCPeer({ stun, turn, websocket, user, room, immediate: false })

All required.

setup()

To setup the connection. If you set options.immediate to be true, you should not run setup() by yourself again.

send(data)

Send data by RTCDataChannel, data can be any type of data.

await peer.send({ msg: 'Hello, there!' })

getMedia(options)

Get user device media, return stream.

let stream = await peer.getMedia({ video: true, audio: false })

stream(stream)

Send stream.

let stream = await peer.getMedia({ video: true, audio: false })
await peer.stream(stream)

receive(type, callback)

Replace callback when you receive data message or stream.

await peer.receive('message', (data) => {
  // ...
})
await peer.receive('streams', (streams) => {
  // ...
})

destory()

Unlink peer connection and destory context.

Events

setup

When setup, only once in the life circle of a peer.

peer.on('setup', () => { ... })

message

When receive a message from remote peer.

peer.on('message', (data) => {
  // ...
})

streams

When receive streams from remote peer.

break

When called to break connection, before destory.

error

When recevie an error message.

peer.on('error', (error) => {})

WebRTCClient

Methods

constructor(options)

options

  • stun: array of objects, required
  • turn: array of objects, required
  • signaling: signaling websocket server url, required, pend token as a query string
let signaling = 'ws://localhost:8686?token=xxxx-xxxx-xxx'
let node = new WebRTCClient({ stun, turn, signaling })

connect({ user, room })

Connect with another user.

node.connect({ user: 100202004 }) // if you do not pass room name, it means you want to create a connect not in a room
node.connect({ user: 100202004, room: 291445 })

Why you need a room name? In fact, in a WebRTCClient instance, you can connect to multiple users (WebRTCPeer can only connect to another peer), with each user using one peer. But some times you may in a chat room, so two users may need more than one connection, pass a room name to certain which to connect.

Return an instance of WebRTCPeer.

destory()

Destory all connections in this node.

Events

offline

When receive a call to offline, before destory.

error

When receive an error message.

websocket server

You should implement your own signaling websokcet server. However I have provided one package:

npm install --save hello-webrtc-server

And then:

const SignalingServer = require('hello-webrtc-server')
const server = new SignalingServer()

And then use ws://your-host.com:8686 as signaling server address to pass into WebRTCClient or WebRTCPeer.