New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

simplevoicerecorderreact

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simplevoicerecorderreact

A modern, feature-rich React voice recorder component with TypeScript support, pause/resume, download, and more

latest
npmnpm
Version
3.0.0
Version published
Maintainers
1
Created
Source

Simple Voice Recorder React

A modern, feature-rich React voice recorder component with TypeScript support, pause/resume functionality, download capability, and comprehensive accessibility features.

Features

  • 🎤 High-quality audio recording using MediaRecorder API
  • ⏸️ Pause/Resume recording functionality
  • 📥 Download recorded audio files
  • 🎨 Modern UI with SCSS styling
  • Accessibility features (ARIA labels, keyboard navigation)
  • 📱 Responsive design for mobile and desktop
  • 🔧 TypeScript support with full type definitions
  • ⏱️ Timer with hours, minutes, and seconds display
  • 🚫 Error handling with user-friendly messages
  • 🎛️ Customizable props for flexible usage
  • 🧹 Memory management with proper cleanup

Installation

npm install simplevoicerecorderreact

or

yarn add simplevoicerecorderreact

Quick Start

import React from 'react';
import { Recorder } from 'simplevoicerecorderreact';
import 'simplevoicerecorderreact/dist/index.css';

const App = () => {
  const handleAudioUrl = (url: string | null) => {
    console.log('Audio URL:', url);
  };

  const handleStatus = (status: 'idle' | 'recording' | 'paused' | 'completed' | 'error') => {
    console.log('Recording status:', status);
  };

  return (
    <Recorder
      blobUrl={handleAudioUrl}
      status={handleStatus}
      title="My Voice Recorder"
    />
  );
};

export default App;

Props

Recorder Component

PropTypeDefaultDescription
blobUrl(url: string | null) => voidundefinedCallback function that receives the audio URL when recording is completed
showAudioPlayUIbooleantrueShow/hide the audio player after recording
titlestring''Title displayed above the recorder
classNamestring''Additional CSS class names
hideAudioTitlebooleanfalseHide the title header
status(status: 'idle' | 'recording' | 'paused' | 'completed' | 'error') => voidundefinedCallback function for recording status changes
onRecordingStart() => voidundefinedCallback fired when recording starts
onRecordingStop() => voidundefinedCallback fired when recording stops
onRecordingPause() => voidundefinedCallback fired when recording is paused
onRecordingResume() => voidundefinedCallback fired when recording resumes
maxDurationnumber0Maximum recording duration in seconds (0 = unlimited)
showDownloadButtonbooleantrueShow/hide the download button
showPauseButtonbooleantrueShow/hide the pause/resume button
showClearButtonbooleantrueShow/hide the clear button
downloadFileNamestring'recording'Default filename for downloaded audio
disabledbooleanfalseDisable all recorder controls

Examples

Basic Usage

import { Recorder } from 'simplevoicerecorderreact';
import 'simplevoicerecorderreact/dist/index.css';

function App() {
  return <Recorder />;
}

With Callbacks

import { Recorder } from 'simplevoicerecorderreact';
import 'simplevoicerecorderreact/dist/index.css';

function App() {
  const handleAudioUrl = (url: string | null) => {
    if (url) {
      console.log('Recording completed:', url);
      // Do something with the audio URL
    }
  };

  const handleStatus = (status: string) => {
    console.log('Status:', status);
  };

  return (
    <Recorder
      blobUrl={handleAudioUrl}
      status={handleStatus}
      title="Voice Recorder"
    />
  );
}

Custom Styling

import { Recorder } from 'simplevoicerecorderreact';
import 'simplevoicerecorderreact/dist/index.css';
import './CustomStyles.scss';

function App() {
  return (
    <Recorder
      className="my-custom-recorder"
      title="Custom Styled Recorder"
    />
  );
}

With Maximum Duration

import { Recorder } from 'simplevoicerecorderreact';
import 'simplevoicerecorderreact/dist/index.css';

function App() {
  return (
    <Recorder
      maxDuration={60} // 60 seconds maximum
      title="60 Second Recorder"
    />
  );
}

Minimal UI (No Audio Player)

import { Recorder } from 'simplevoicerecorderreact';
import 'simplevoicerecorderreact/dist/index.css';

function App() {
  const handleAudioUrl = (url: string | null) => {
    // Handle audio URL programmatically
    if (url) {
      // Upload to server, etc.
    }
  };

  return (
    <Recorder
      showAudioPlayUI={false}
      blobUrl={handleAudioUrl}
      title="Minimal Recorder"
    />
  );
}

Using the Hook Directly

For more control, you can use the useRecorder hook directly:

import { useRecorder } from 'simplevoicerecorderreact';
import 'simplevoicerecorderreact/dist/index.css';

function CustomRecorder() {
  const {
    audioURL,
    isRecording,
    isPaused,
    startRecording,
    stopRecording,
    pauseRecording,
    resumeRecording,
    clearRecording,
    error,
    audioBlob,
  } = useRecorder();

  return (
    <div>
      {error && <div>Error: {error}</div>}
      <button onClick={startRecording} disabled={isRecording}>
        Start
      </button>
      <button onClick={stopRecording} disabled={!isRecording}>
        Stop
      </button>
      {isRecording && (
        <button onClick={isPaused ? resumeRecording : pauseRecording}>
          {isPaused ? 'Resume' : 'Pause'}
        </button>
      )}
      {audioURL && <audio controls src={audioURL} />}
    </div>
  );
}

Next.js Usage

// pages/index.tsx or app/page.tsx
import { Recorder } from 'simplevoicerecorderreact';
import 'simplevoicerecorderreact/dist/index.css';

export default function Home() {
  return (
    <div>
      <h1>Voice Recorder</h1>
      <Recorder />
    </div>
  );
}

Browser Support

This component uses the MediaRecorder API, which is supported in:

  • Chrome 47+
  • Firefox 25+
  • Edge 79+
  • Safari 14.1+
  • Opera 36+

For older browsers, you may need polyfills.

TypeScript

Full TypeScript support is included. Import types as needed:

import { Recorder, RecorderProps, UseRecorderReturn } from 'simplevoicerecorderreact';

Styling

Important: You must import the CSS file for the component to display correctly:

import 'simplevoicerecorderreact/dist/index.css';

The component uses SCSS modules. You can override styles by:

  • Passing a className prop
  • Using CSS specificity to override default styles
  • Importing the styles module and extending it

Accessibility

The component includes:

  • ARIA labels and roles
  • Keyboard navigation support
  • Screen reader announcements
  • Focus management
  • Semantic HTML

Error Handling

The component handles various error scenarios:

  • Microphone permission denied
  • Microphone not available
  • MediaRecorder API not supported
  • Recording errors

Errors are displayed to the user and can be accessed via the error property when using the hook directly.

Performance

  • Proper cleanup of MediaRecorder and MediaStream
  • Memory management with URL.revokeObjectURL
  • Efficient timer implementation using setInterval
  • No memory leaks

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

ISC

Author

Ahmad Faraz

Changelog

Version 3.0.0

  • ✨ Added TypeScript support
  • ✨ Added pause/resume functionality
  • ✨ Added download button
  • ✨ Added clear button
  • ✨ Improved error handling
  • ✨ Enhanced accessibility features
  • ✨ Better timer implementation
  • ✨ SCSS styling
  • ✨ Memory leak fixes
  • ✨ Better cleanup on unmount
  • ✨ More customization options

Version 2.1.3

  • Basic recording functionality
  • Audio playback UI
  • Timer display

Keywords

react

FAQs

Package last updated on 22 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts