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

@ananay-nag/react-voice-recorder

v1.0.4

Published

React component to record voice and store as blob data.

Readme

React Voice Recorder with Compression

A lightweight, customizable React voice recorder component with automatic audio compression.

Demo App

  • https://react-voice-demo-app.vercel.app/

Features

  • 🎙️ Simple voice recording with automatic compression
  • ⏱️ Configurable recording duration
  • 🗜️ Multiple compression levels (none, low, medium, high)
  • 🔊 Built-in audio playback
  • 📊 File size reporting
  • 🎛️ Audio enhancement (noise suppression, echo cancellation)
  • 📱 Mobile-friendly and responsive

Installation

npm install @ananay-nag/react-voice-recorder
# or
yarn add @ananay-nag/react-voice-recorder

Components

VoiceRecorder

The primary component that handles recording audio with compression.

import { VoiceRecorder } from '@ananay-nag/react-voice-recorder';

function MyRecorder() {
  const handleDataRecorded = (data) => {
    console.log('Audio recorded:', data);
    // data contains: blob, url, type, isRecording, size
  };

  return (
    <VoiceRecorder 
      onDataRecorded={handleDataRecorded} 
      duration={60} 
      compressionLevel="medium" 
    />
  );
}

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | onDataRecorded | function | - | Callback function that receives recorded audio data | | duration | number | 60 | Maximum recording duration in seconds | | compressionLevel | string | 'medium' | Compression level: 'none', 'low', 'medium', or 'high' |

Data Structure

The onDataRecorded callback receives an object with:

{
  blob: Blob;           // The audio data blob
  url: string;          // Object URL for the audio blob
  type: string;         // MIME type of the audio (e.g., "audio/webm")
  isRecording: boolean; // Recording status
  size?: number;        // File size in KB
}

PreviewVoiceNote

Component for playing back recorded audio with file information.

import { PreviewVoiceNote } from '@ananay-nag/react-voice-recorder';

function AudioPlayer({ audioUrl }) {
  return (
    <PreviewVoiceNote 
      audioUrl={audioUrl} 
    />
  );
}

Props

| Prop | Type | Description | |------|------|-------------| | audioUrl | string | null | URL to the audio file |

RecordingStatus

A simple component that displays a recording indicator.

import { RecordingStatus } from '@ananay-nag/react-voice-recorder';

function MyRecordingApp({ isCurrentlyRecording }) {
  return (
    <div>
      <RecordingStatus isRecording={isCurrentlyRecording} />
    </div>
  );
}

Props

| Prop | Type | Description | |------|------|-------------| | isRecording | boolean | Whether recording is in progress |

AudioSize

A utility function to calculate the size of an audio blob in KB.

import { AudioSize } from '@ananay-nag/react-voice-recorder';

function MyAudioInfo({ audioData }) {
  const sizeInKB = AudioSize(audioData);
  
  return <div>File size: {sizeInKB} KB</div>;
}

Parameters

| Parameter | Type | Description | |-----------|------|-------------| | audioData | { blob: Blob | null } | Object containing an audio blob |

Compression Details

The component supports four compression levels:

| Level | Format | Bitrate | Description | |-------|--------|---------|-------------| | none | WAV | - | Uncompressed audio for highest quality | | low | WebM | 96 kbps | Low compression, good quality | | medium | WebM | 64 kbps | Balanced compression (default) | | high | WebM | 32 kbps | High compression, smaller file size |

Complete Example

import React, { useState } from "react";
import {
  PreviewVoiceNote,
  VoiceRecorder,
  RecordingStatus,
  AudioSize,
} from "@ananay-nag/react-voice-recorder";

function App() {
  const [audioData, setAudioData] = useState<{
    blob: Blob;
    url: string;
    isRecording: boolean;
    size?: number | 0;
  } | null>(null);

  const handleRecordedData = (
    data: {
      blob: Blob;
      url: string;
      type: string;
      isRecording: boolean;
      size?: number;
    }
  ) => {
    setAudioData(data);

    // Now you can do whatever you want with the data:
    // - Store it in state
    // - Send it to a server
    // - Process it further

    // Example of sending to server:
    // sendToServer(data.blob);
  };

  return (
    <div className="App">
      <h1>My Voice Recording App</h1>
      <VoiceRecorder
        onDataRecorded={handleRecordedData}
        duration={10}
        compressionLevel={"low"}
      />
      <RecordingStatus isRecording={audioData?.isRecording ?? false} />

      {audioData && (
        <PreviewVoiceNote audioUrl={audioData?.url ?? null}></PreviewVoiceNote>
      )}

      {audioData && (
        <div>
          {audioData.size!= 0 && (
            <p>
              Size: <AudioSize size={audioData?.blob?.size ?? null} />
            </p>
          )}
        </div>
      )}
    </div>
  );
}

// Example function to send data to server
// function sendToServer(audioBlob: Blob) {
//   const formData = new FormData();
//   formData.append('audio', audioBlob, 'recording.wav');

//   fetch('/api/upload-audio', {
//     method: 'POST',
//     body: formData
//   })
//   .then(response => response.json())
//   .then(data => console.log('Success:', data))
//   .catch(error => console.error('Error:', error));
// }

export default App;

Browser Compatibility

  • Chrome 49+
  • Firefox 53+
  • Safari 11+
  • Edge 79+

CSS Styling

The component includes basic styling, but you can customize it by overriding the CSS classes:

/* Example custom styling */
.voice-recorder-container {
  background-color: #f7f9fc;
  border-radius: 8px;
  padding: 20px;
}

.record-button {
  font-weight: bold;
}

.audio-player {
  width: 100%;
  margin-top: 10px;
}

License

ISC