
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
react-voice-recorder-player
Advanced tools
Say goodbye to boring audio elments and hello to interactive voice recording! react-voice-recorder-player is a React component that lets users record and playback their voice directly in the browser. It even includes a waveform graph that shows the audio being captured and played back in real-time.
react-voice-recorder-player is an ultra light-weight component. The package size is only around 160 kB meaning it won't add unnecessary bulk to your application. And the best part is, its completely customizable! You can easily change the appearance of the component to fit your application's unique design and trigger your own code on our custom events.
The package can be installed via npm:
npm install react-voice-recorder-player --save
Or via yarn:
yarn add react-voice-recorder-player
Check out the CodePen demo to see the VoiceRecorder component in action. This demo is a great starting point for customizing the component to fit your application's unique design.
Using the VoiceRecorder component is a breeze. Simply import it into your React application like so:
import React from 'react';
import { VoiceRecorder } from 'react-voice-recorder-player';
function App() {
return (
<div>
<h1>React Voice Recorder</h1>
<VoiceRecorder />
</div>
);
}
export default App;
The VoiceRecorder component will provide your users with an intuitive MP3-like interface, complete with record, play, pause, and stop buttons.
VoiceRecorder component uses the MediaRecorder API to record audio. This means that the component will only work in browsers that support this API. You can check out the browser compatibility table to see which browsers support this API.false to the downloadable prop. If you'd like to obtain the audio file link programmatically, you can pass in a callback function to the onAudioDownload prop. This callback function will be called with the audio file blob as an argument.| Prop name | Description | Type |
|---|---|---|
mainContainerStyle | Style object for the container of the whole component. | CSSProperties |
height | Height of the component. | number,string |
width | Width of the component. | number,string |
controllerContainerStyle | Style object for the container of the controller buttons. | CSSProperties |
controllerStyle | Style object for the controller buttons. | CSSProperties |
waveContainerStyle | Style object for the container of the waveform graph. | CSSProperties |
graphColor | Color of the waveform graph. | string |
graphShaded | Boolean value indicating if the waveform graph should be shaded according to the amplitude of the audio. true by default. | boolean |
downloadable | Boolean value indicating if the download button should be displayed to the user when they're done recording. true by default. | boolean |
uploadAudioFile | Boolean value indicating if the upload button should be displayed to the user. true by default. | boolean |
onAudioDownload | A callback function that'll get called as soon as the Blob is available. | Function |
In addition to the props mentioned above, you can also use our custom callback events to trigger specific actions in your application. Here's a list of the custom events that are available:
| Prop name | Description | Type |
|---|---|---|
onRecordingStart | Event triggered when recording starts | function |
onRecordingEnd | Event fired when recording ends | function |
onPlayStart | Event triggered when playback starts | function |
onPlayEnd | Event fired when playback ends | function |
onRecordingPause | Event triggered when recording is paused | function |
onPlayPause | Event fired when playback is paused | function |
Want to make the VoiceRecorder component even more personalized? No problem! You can customize the appearance of the component by passing in your own style objects. Here's an example:
import React from 'react';
import { VoiceRecorder } from 'react-voice-recorder-player';
function MyComponent() {
const styles = {
mainContainerStyle: {
backgroundColor: 'gray',
border: '1px solid black',
borderRadius: '5px',
padding: '10px'
},
controllerContainerStyle: {
display: 'flex',
justifyContent: 'space-between',
marginTop: '10px'
},
controllerStyle: {
backgroundColor: 'white',
border: '1px solid black',
borderRadius: '5px',
cursor: 'pointer',
padding: '5px'
},
waveContainerStyle: {
height: '100px',
marginTop: '10px',
width: '100%'
}
};
return (
<VoiceRecorder
mainContainerStyle={styles.mainContainerStyle}
controllerContainerStyle={styles.controllerContainerStyle}
controllerStyle={styles.controllerStyle}
waveContainerStyle={styles.waveContainerStyle}
/>
);
}
This section provides solutions for known issues related to browser compatibility:
Please note that this list may be updated as new issues are identified and resolved. Contributions from the community are welcome in identifying and fixing any bugs. We appreciate your help in making this project better!
We welcome contributions to improve react-voice-recorder-player. To contribute, please follow these steps:
If you encounter any issues while using react-voice-recorder-player, please feel free to open an issue on the project's GitHub repository. We welcome bug reports, feature requests, and other contributions from the community.
react-voice-recorder-player is licensed under the MIT License. See the LICENSE file for more information.
|
Abreeza Saleem abreeza.saleem@hotmail.com https://abreeza.tech |
FAQs
Voice Recorder Component for React
We found that react-voice-recorder-player 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.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.