
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
use-voice-recorder
Advanced tools
React hook for recording users' audio.
This project is using MediaRecorder as its underhood.
See full example in /example folder
First you need to call hook with a callback function. This callback gets Blob with a recorded audio after recording was stopped.
Hook provide 3 methods:
const Recorder: React.FC<{
onRecorded: (data: Blob) => void
}> = ({onRecorded}) => {
const {isRecording, stop, start} = useVoiceRecorder(onRecorded);
return (
<div>
<div>
On air: {isRecording ? 'on' : 'off'}
</div>
<button onClick={start}>Start</button>
<button onClick={stop}>Stop</button>
</div>
)
};
Audio is stored as Blob format, so if you want to play a record you may create link with
window.URL.createObjectURL(blobAudio).
const Player: React.FC<{
audioBlob: Blob
}> = ({audioBlob}) => {
const link = window.URL.createObjectURL(audioBlob)
return <audio src={link} controls />
};
Full example:
import * as React from "react";
import { useVoiceRecorder } from "use-voice-recorder";
import { useState } from "react";
export const App: React.FC = () => {
const [records, updateRecords] = useState([]);
const {isRecording, stop, start} = useVoiceRecorder((data) => {
updateRecords([...records, window.URL.createObjectURL(data)]);
});
return (
<div>
<h1>Voices:</h1>
<div>
<h3>On air: {isRecording ? 'on' : 'off'}</h3>
<button onClick={start}>Start</button>
<button onClick={stop}>Stop</button>
</div>
<div>
<h1>Records:</h1>
{records.map((data, idx) => (
<div key={idx}>
<audio src={data} controls preload={'metadata'} />
</div>
))}
</div>
</div>
)
};
This hook is using MediaRecorder API, so you need to check the browser compatibility before useing it: https://developer.mozilla.org/en-US/docs/Web/API/MediaStream_Recording_API
Also, there are different browsers that provide different codecs and audio formats. Be careful about this. You can check supported codecs with this method MediaRecorder.isTypeSupported
If you want to polyfill MediaRecorder, you can use Evil Martians Solution.
FAQs
React hook for recording media from user device
The npm package use-voice-recorder receives a total of 10 weekly downloads. As such, use-voice-recorder popularity was classified as not popular.
We found that use-voice-recorder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.