npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-microphone-recorder

v1.0.0

Published

A convenient and powerful React hook and component for audio recording with customizable options and audio levels.

Downloads

424

Readme

react-microphone-recorder

A convenient and powerful React hook and component for audio recording with customizable options and audio levels.

recorder-demo.gif

Live Demo

Deploy with Vercel

Table of Contents

Features

  1. useRecorder - A React hook that provides audio recording functionalities and exposes several useful properties.
  2. RecordAudio - A pre-built, beautifully designed React component for audio recording.
  3. Full TypeScript support.

Installation

Using npm:

npm install react-microphone-recorder

Or using yarn:

yarn add react-microphone-recorder

Usage

useRecorder

import { useRecorder } from 'react-microphone-recorder';

function MyComponent() {
  const { audioLevel, startRecording, pauseRecording, stopRecording, resetRecording, time, audioURL, recordingState, isRecording, audioFile } = useRecorder();

  // use these values in your component
}

Properties exposed by useRecorder:

  • audioLevel: A floating-point number that changes with the microphone audio recording levels as the user starts recording.
  • startRecording, pauseRecording, stopRecording, resetRecording, resumeRecording: Functions to control the recording.
  • timeElapsed: A number that represents the time elapsed since the recording started.
  • recordingState: A string that represents the current recording state. Can be one of "idle", "recording", "stopped", "paused".
  • isRecording: A boolean that indicates whether the recording is currently active.
  • audioURL: A string that holds the URL of the recorded audio. recordingState: A string that represents the current recording state. Can be one of "idle", "recording", "stopped", "paused".
  • isRecording: A boolean that indicates whether the recording is currently active.
  • audioFile: A File object that represents the recorded audio in "mp3" format.
  • audioBlob: A Blob object that represents the recorded audio in mp3 format. audioFile, audioURL are created from this blob.

RecordAudio

Simply import the RecordAudio component and all you need to do is pass the audioFile property to it. The component will take care of the rest.

import { RecordAudio } from 'react-microphone-recorder'

function MyComponent() {
  // ... get audioURL and audioFile ...
  const [audioFile, setAudioFile] = (useState < File) | (undefined > undefined)

  return <RecordAudio audioFile={audioFile} />
}

RecordAudio

Warning The RecordAudio component is styled using Tailwind CSS. It's important to note that the styles will only be correctly applied if your project is set up with Tailwind CSS. If your project does not use Tailwind CSS, the component will still function correctly, but it will not have the intended visual style. If you are not using Tailwind CSS and still want to use the RecordAudio component, you may need to manually adjust the styles to suit your project's styling solution. Alternatively, consider setting up Tailwind CSS in your project, which can be done following the instructions on the official Tailwind CSS documentation.

Note Use useRecorder if you want to build your own custom UI for audio recording.

Contributing

Contributions are welcome! Please open an issue or submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.