
Security News
/Research
npm Phishing Email Targets Developers with Typosquatted Domain
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.
use-audio-capture
Advanced tools
ποΈ A lightweight React hook for audio recording using native Web APIs (MediaRecorder, getUserMedia). Start, stop, pause, resume audio recordings with customizable callbacks. Perfect for voice notes, interviews, podcasts, and real-time audio processing in
A lightweight, zero-dependency React hook for audio recording using native Web APIs (MediaRecorder, getUserMedia). Perfect for building voice notes, podcasts, interviews, and real-time audio processing applications in React.
Stop struggling with complex audio libraries! This React hook leverages native browser APIs to provide:
npm install use-audio-capture
yarn add use-audio-capture
pnpm add use-audio-capture
Perfect for building:
import { useAudioCapture } from 'use-audio-capture';
export const VoiceRecorder = () => {
const { start, stop, pause, resume } = useAudioCapture({
onStart: () => console.log('ποΈ Recording started'),
onChunk: (blobEvent) => console.log('Blob event here'),
onStop: (event, chunks) => {
// You can create audio file from recorded chunks on stop
const blob = new Blob(chunks, { type: chunks[0].type });
const file = new File([blob], 'sampleFile.webm', {
type: chunks[0].type,
});
console.log(file);
},
onError: (_event, { error }) => {
console.error('Recording error:', error);
},
});
return (
<div>
<button onClick={start}>ποΈ Start Recording</button>
<button onClick={stop}>βΉοΈ Stop</button>
<button onClick={pause}>βΈοΈ Pause</button>
<button onClick={resume}>βΆοΈ Resume</button>
</div>
);
};
π See Live Example | π¨ Storybook Demo
Component example built based on use-audio-capture hook - See live example
const { start, stop, pause, resume } = useAudioCapture(options);
Function | Description | Usage |
---|---|---|
start() | Start audio recording | await start() |
stop() | Stop recording and trigger onStop callback | await stop() |
pause() | Pause current recording session | await pause() |
resume() | Resume paused recording | await resume() |
Callback | Triggered When | Parameters |
---|---|---|
onStart | Recording begins | (event, { mediaStream }) |
onChunk | New audio data available | (blobEvent, { mediaStream }) |
onStop | Recording stops | (event, chunks[], { mediaStream }) |
onPause | Recording paused | (event, chunks[], { mediaStream }) |
onResume | Recording resumed | (event, chunks[], { mediaStream }) |
onError | Error occurs | (event, { mediaStream, error }) |
This hook works in all modern browsers that support:
Browser | Support |
---|---|
Chrome | β 47+ |
Firefox | β 29+ |
Safari | β 14+ |
Edge | β 79+ |
MIT Β© breeg554
Keywords: react hook, audio recording, web api, mediarecorder, getusermedia, voice notes, podcast, interview, real-time audio, browser recording, typescript, react audio, voice recorder, audio capture, microphone access
FAQs
ποΈ A lightweight React hook for audio recording using native Web APIs (MediaRecorder, getUserMedia). Start, stop, pause, resume audio recordings with customizable callbacks. Perfect for voice notes, interviews, podcasts, and real-time audio processing in
We found that use-audio-capture demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.
Security News
Knip hits 500 releases with v5.62.0, refining TypeScript config detection and updating plugins as monthly npm downloads approach 12M.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.