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

streams-recorder

v0.1.4

Published

Browser audio recorder that mixes multiple live MediaStreams with pause/resume that survives track dropouts and AudioContext interruptions.

Readme

streams-recorder

Browser audio recorder that mixes multiple live MediaStreams into one MediaRecorder timeline. Built for reliability: mute, unplug, and AudioContext interruptions should pause instead of writing empty chunks or getting stuck.

Try the live demo — mix your microphone with tab or system audio and download the result.

This is an early release for feedback. Please open issues with browser + OS details when something fails.

Browser only. There is no Node runtime.

Install

pnpm add streams-recorder
npm install streams-recorder

Usage

Acquire streams yourself (getUserMedia, getDisplayMedia, WebRTC, etc.), then attach them by key:

import { streamsRecorder } from 'streams-recorder'

const chunks: Blob[] = []

const recorder = streamsRecorder({
  onDataAvailable: event => chunks.push(event.data),
  onStateChange: state => console.log(state),
  onActiveSourcesChange: keys => console.log('live sources', keys),
  onError: (error, context) => console.error(error, context),
})

const mic = await navigator.mediaDevices.getUserMedia({ audio: true })
await recorder.changeSourceStream('mic', mic)

await recorder.startRecording() // timeslice defaults to 5000ms
// recorder.pauseRecording() / resumeRecording()
await recorder.stopRecording()

const blob = new Blob(chunks, { type: chunks[0]?.type ?? 'audio/webm' })

Add or replace sources at any time. Pass null to detach a key:

const display = await navigator.mediaDevices.getDisplayMedia({ video: true, audio: true })
await recorder.changeSourceStream('display', display)
await recorder.changeSourceStream('mic', null)

State machine:

stateDiagram-v2
  [*] --> idle
  idle --> ready: attach a live stream
  ready --> idle: last live track ends or is detached
  ready --> recording: startRecording()
  recording --> paused: pause, tracks dropped, or AudioContext suspended
  paused --> recording: resume, re-attach after auto-pause, or context running
  idle --> stopped: stopRecording() / cleanup()
  ready --> stopped: stopRecording() / cleanup()
  recording --> stopped: stopRecording()
  paused --> stopped: stopRecording()

stopped is terminal. Each instance is single-use — after stopRecording() or cleanup(), create a new one (in React/Vue, remount the component).

Public API

| Member | Role | | --- | --- | | streamsRecorder(options) | Create a mixer + MediaRecorder on an AudioContext destination. | | changeSourceStream(key, stream \| null) | Connect, replace, or detach a named input stream. | | startRecording(timeslice?) | Start capturing; requires ready and at least one live track. | | pauseRecording() / resumeRecording() | Pause/resume the recorder timeline. | | stopRecording() | Stop and close the audio graph (stops input tracks unless skipTrackStop). | | cleanup() | Tear down without requiring an active recording. | | getDurationMs() | Elapsed recording time excluding pauses. | | recordingState / stream / audioContext | Current state, mixed output stream, and context. | | getSupportedMimeType() / getRecorderMimeType() | Pick a MediaRecorder mime the browser actually supports. |

Reliability behavior

  • All tracks ended: auto-pauses so the timeline does not keep emitting empty data; attaching a live stream can auto-resume. If nothing is recording, state drops from ready back to idle.
  • AudioContext suspended / interrupted: auto-pause, then auto-resume when the context is running again (phone calls, tab freeze, iOS).
  • Mime fallback: prefers audio/webm;codecs=opus, then Safari audio/mp4.

React and Vue helpers are optional subpath exports. Install the matching framework as a peer if you use them.

React

import { useStreamsRecorder } from 'streams-recorder/react'

const { recordingState, changeSourceStream, startRecording, stopRecording, getDurationMs } = useStreamsRecorder({
  onDataAvailable: event => chunks.push(event.data),
})

The instance is created once per component mount. After stopRecording(), remount the component (for example key={session}) to get a new recorder. Duration is not tracked in the hook — call getDurationMs() yourself.

Vue

import { useStreamsRecorder } from 'streams-recorder/vue'

const { recordingState, changeSourceStream, startRecording, stopRecording, getDurationMs } = useStreamsRecorder({
  onDataAvailable: event => chunks.push(event.data),
})

Same single-use rule: remount the component (:key) after stop. Poll getDurationMs() in the app if you need a timer.

Examples

The React example is deployed at vaibhav11s.github.io/streams-recorder. To run any of them locally, clone this repo, then:

pnpm install
pnpm dev:vanilla   # microphone + optional display audio, download on stop
pnpm dev:react     # same demo in React
pnpm dev:vue       # same demo in Vue, with a microphone device picker

The vanilla example is the easiest place to try multi-source mixing. React and Vue wrap the same recorder API.

Feedback

Useful reports include: browser + version, OS, whether sources were mic / tab / system audio, and whether the failure was start, pause, device unplug, or backgrounding the tab.