react-native-waveform-recorder
v1.1.0
Published
High-performance React Native audio recorder with a native live waveform, multi-segment record/pause/resume, in-place preview + scrub playback, slide-to-cancel / slide-to-lock gestures, silence detection, and a WhatsApp-style 64-bucket export. Built on th
Maintainers
Keywords
Readme
react-native-waveform-recorder
A React Native audio recorder with a native live waveform, pause and resume, in-place preview with scrubbing, continue recording after preview, slide-to-cancel and slide-to-lock gestures, silence detection and a 64-bar export ready for chat bubbles. Built for the New Architecture (Fabric); nothing runs in JavaScript per frame.
Pairs with react-native-waveform-player for playback: pass onComplete.uri and onComplete.samples to it and the player skips decoding the file. Works with Expo development builds (not Expo Go).
Demo
| iOS | Android | | :---: | :---: | | | |
Features
- Native live waveform: bars drawn in Swift and Kotlin from the microphone level, with configurable colors, sizes, timer and placeholder ticks
- Pause, preview, continue: pause and resume, listen back with scrubbing, then record more; segments are joined into one file
- Slide to cancel or lock: native drag tracking with progress events for your own hints
- Silence detection: an event after a quiet stretch, optionally stopping automatically
- 64-bar export:
onComplete.samplesis ready for a chat-bubble waveform - Formats:
m4a,aac,wavandopus - Raw PCM stream: opt-in 16-bit PCM chunks while recording WAV, from the
/pcm-streamsubpath - Background recording: iOS background audio and an Android foreground service
Install
npm install react-native-waveform-recorder
# or
yarn add react-native-waveform-recorder
# iOS
npx pod-installRequires the New Architecture. Add NSMicrophoneUsageDescription to your iOS Info.plist; Android's RECORD_AUDIO is declared by the library and requested on start(). For Expo, add "react-native-waveform-recorder" to plugins and rebuild your development client. Background recording and the config plugin options are covered in the installation guide.
Quick start
import { useRef } from 'react';
import { Button, View } from 'react-native';
import {
WaveformRecorderView,
type WaveformRecorderViewRef,
} from 'react-native-waveform-recorder';
export function VoiceNote() {
const ref = useRef<WaveformRecorderViewRef>(null);
return (
<View>
<WaveformRecorderView
ref={ref}
style={{ height: 56 }}
onComplete={(e) => {
// Copy e.uri somewhere permanent: cancel() or unmounting the view deletes the session files.
console.log('saved:', e.uri, e.durationMs, e.samples.length);
}}
/>
<Button title="Record" onPress={() => ref.current?.start()} />
<Button title="Stop" onPress={() => ref.current?.stop()} />
</View>
);
}Documentation
Everything else lives on the documentation site: https://maitrungduc1410.github.io/react-native-waveform-recorder/
- Props, events and ref methods
- Segments, pause and preview
- Slide gestures and silence detection
- Export and the player and the PCM stream
- Platform notes and troubleshooting
A demo app with recipe screens is in example/. Design notes are in ARCHITECTURE.md and LESSONS_LEARNED.md.
Contributing
See CONTRIBUTING.md. The docs site source is in docs/; run yarn docs:dev to work on it.
License
MIT
