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

webrtc-easy

v0.1.0

Published

Easy to use WebRTC library for multiple frontend frameworks

Readme

WebRTC Easy

A simple, flexible WebRTC library for multiple frontend frameworks.

Features

  • 🔄 Easy WebRTC connection management
  • 🎥 Media stream handling (camera, microphone, screen sharing)
  • 📊 Network quality monitoring and adaptation
  • 🔌 Data channel support
  • 🎨 Media processing (audio effects, video filters)
  • 🛠️ Framework integrations:
    • React
    • Vue
    • Angular
    • Svelte

Installation

npm install webrtc-easy

Building from Source

To build the library from source:

  1. Clone the repository

    git clone https://github.com/yourusername/webrtc-easy.git
    cd webrtc-easy
  2. Install dependencies

    npm install
  3. Build the library

    npm run build

This will create the following outputs:

  • TypeScript declarations in dist/
  • CommonJS modules in dist/
  • Browser bundle in dist/webrtc-easy.min.js

Running Examples

The package includes several examples demonstrating different features:

Signaling Server

Start the signaling server (required for most examples):

npm run start:signaling

This will start a WebSocket signaling server on port 3000.

File Sharing Example

Open examples/file-sharing/index.html in your browser to try the file sharing example.

Audio Effects Example

Open examples/audio-effects/index.html in your browser to try the audio effects example.

Screen Recording Example

Open examples/screen-recording/index.html in your browser to try the screen recording example.

Basic Usage

Core API

import { RTCConnection, WebSocketSignaling } from 'webrtc-easy';

// Create a signaling connection
const signaling = new WebSocketSignaling({
  url: 'wss://your-signaling-server.com',
  room: 'test-room'
});

// Create a WebRTC connection
const connection = new RTCConnection({
  configuration: {
    iceServers: [{ urls: 'stun:stun.l.google.com:19302' }]
  }
});

// Get user media
const stream = await navigator.mediaDevices.getUserMedia({
  video: true,
  audio: true
});

// Add stream to connection
connection.addStream(stream);

// Set up signaling
signaling.onMessage(async (message) => {
  switch (message.type) {
    case 'offer':
      const answer = await connection.createAnswer(message.payload);
      signaling.send({ type: 'answer', payload: answer });
      break;
    case 'answer':
      await connection.handleAnswer(message.payload);
      break;
    case 'ice-candidate':
      await connection.addIceCandidate(message.payload);
      break;
  }
});

// Create and send offer
const offer = await connection.createOffer();
signaling.send({ type: 'offer', payload: offer });

React Integration

import React, { useRef, useEffect } from 'react';
import { useWebRTC } from 'webrtc-easy/react';
import { WebSocketSignaling } from 'webrtc-easy/core';

const VideoChat = () => {
  const localVideoRef = useRef<HTMLVideoElement>(null);
  const remoteVideoRef = useRef<HTMLVideoElement>(null);

  const {
    localStream,
    remoteStream,
    connection,
    connectionState,
    error,
    initConnection,
    startScreenShare
  } = useWebRTC({
    configuration: {
      iceServers: [{ urls: 'stun:stun.l.google.com:19302' }]
    }
  });

  useEffect(() => {
    if (localVideoRef.current && localStream) {
      localVideoRef.current.srcObject = localStream;
    }
  }, [localStream]);

  useEffect(() => {
    if (remoteVideoRef.current && remoteStream) {
      remoteVideoRef.current.srcObject = remoteStream;
    }
  }, [remoteStream]);

  const handleStart = async () => {
    const conn = await initConnection();

    const signaling = new WebSocketSignaling({
      url: 'wss://your-signaling-server.com',
      room: 'test-room'
    });

    signaling.onMessage(async (message) => {
      switch (message.type) {
        case 'offer':
          const answer = await conn.createAnswer(message.payload);
          signaling.send({ type: 'answer', payload: answer });
          break;
        case 'answer':
          await conn.handleAnswer(message.payload);
          break;
        case 'ice-candidate':
          await conn.addIceCandidate(message.payload);
          break;
      }
    });

    const offer = await conn.createOffer();
    signaling.send({ type: 'offer', payload: offer });
  };

  return (
    <div>
      <button onClick={handleStart}>Start Call</button>
      <button onClick={startScreenShare}>Share Screen</button>

      <div>
        <h3>Local Video</h3>
        <video ref={localVideoRef} autoPlay muted playsInline />
      </div>

      <div>
        <h3>Remote Video</h3>
        <video ref={remoteVideoRef} autoPlay playsInline />
      </div>
    </div>
  );
};

Vue Integration

<template>
  <div>
    <button @click="handleStart">Start Call</button>
    <button @click="startScreenShare">Share Screen</button>

    <div>
      <h3>Local Video</h3>
      <video ref="localVideo" autoplay muted playsinline />
    </div>

    <div>
      <h3>Remote Video</h3>
      <video ref="remoteVideo" autoplay playsinline />
    </div>
  </div>
</template>

<script setup>
import { ref, watch } from 'vue';
import { useWebRTC } from 'webrtc-easy/vue';
import { WebSocketSignaling } from 'webrtc-easy/core';

const localVideo = ref(null);
const remoteVideo = ref(null);

const {
  localStream,
  remoteStream,
  connection,
  connectionState,
  error,
  initConnection,
  startScreenShare
} = useWebRTC({
  configuration: {
    iceServers: [{ urls: 'stun:stun.l.google.com:19302' }]
  }
});

watch(localStream, (stream) => {
  if (localVideo.value && stream) {
    localVideo.value.srcObject = stream;
  }
});

watch(remoteStream, (stream) => {
  if (remoteVideo.value && stream) {
    remoteVideo.value.srcObject = stream;
  }
});

const handleStart = async () => {
  const conn = await initConnection();

  const signaling = new WebSocketSignaling({
    url: 'wss://your-signaling-server.com',
    room: 'test-room'
  });

  signaling.onMessage(async (message) => {
    switch (message.type) {
      case 'offer':
        const answer = await conn.createAnswer(message.payload);
        signaling.send({ type: 'answer', payload: answer });
        break;
      case 'answer':
        await conn.handleAnswer(message.payload);
        break;
      case 'ice-candidate':
        await conn.addIceCandidate(message.payload);
        break;
    }
  });

  const offer = await conn.createOffer();
  signaling.send({ type: 'offer', payload: offer });
};
</script>

Advanced Features

Network Quality Monitoring

import { RTCConnection } from 'webrtc-easy';

const connection = new RTCConnection({
  networkQuality: {
    enabled: true,
    onQualityChange: (metrics) => {
      console.log('Network quality:', metrics.quality);
      console.log('Score:', metrics.score);
      console.log('Round trip time:', metrics.roundTripTime, 'ms');
      console.log('Packet loss:', metrics.packetLoss, '%');
    }
  }
});

Adaptive Streaming

import { RTCConnection } from 'webrtc-easy';

const connection = new RTCConnection({
  adaptiveStreaming: {
    enabled: true,
    config: {
      maxBitrate: 2500, // kbps
      minBitrate: 100,  // kbps
      targetQuality: 0.8 // 0-1 scale
    }
  }
});

// Start adaptive streaming
connection.startAdaptiveStreaming();

Data Channels

import { RTCConnection } from 'webrtc-easy';

const connection = new RTCConnection();

// Create a data channel
const channel = connection.createDataChannel('chat');

// Send data
connection.sendData('chat', 'Hello, world!');

// Receive data
connection.onDataChannelMessage('chat', (data) => {
  console.log('Received:', data);
});

API Reference

For detailed API documentation, see the API Reference.

Examples

Check out the examples directory for complete working examples.

License

MIT