Gathering detailed insights and metrics for react-use-audio-player-guru
Gathering detailed insights and metrics for react-use-audio-player-guru
Gathering detailed insights and metrics for react-use-audio-player-guru
Gathering detailed insights and metrics for react-use-audio-player-guru
React hooks for controlling audio on the web
npm install react-use-audio-player-guru
Typescript
Module System
Node Version
NPM Version
71.3
Supply Chain
98
Quality
75
Maintenance
100
Vulnerability
100
License
TypeScript (87.87%)
JavaScript (12.13%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
345 Stars
189 Commits
39 Forks
7 Watchers
4 Branches
8 Contributors
Updated on Jul 10, 2025
Latest Version
0.0.20
Package Id
react-use-audio-player-guru@0.0.20
Unpacked Size
97.90 kB
Size
19.46 kB
File Count
17
NPM Version
6.14.4
Node Version
13.12.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
1
A custom React hook for controlling browser audio powered by the amazing howler.js library. The intention of this package is to abstract away the details of howler's API using built-in React primitives to create an interface that is more React-friendly, allowing you to write React code that is free from audio-related side-effects.
1yarn add react-use-audio-player
For convenience, the library's type definitions are included in the package under index.d.ts
.
This library exports a context Provider and two hooks for controlling an audio source, giving you the tools you need to build you own audio player or visualization.
AudioPlayerProvider
This Provider is required for the hooks to function.
The Provider contains a single audio source and exposes an interface for manipulating it via the useAudioPlayer
hook.
The benefit of having a single, shared audio source is that it allows the developer to compose together multiple components that share knowledge about the audio.
For example, you may have separate components PlayPauseButton
, SeekBar
and VolumeControls
all working together on the same audio source.
1import React from "react" 2import { AudioPlayerProvider } from "react-use-audio-player" 3 4const App = () => { 5 return ( 6 <AudioPlayerProvider> 7 <AudioPlayer file="meow.mp3" /> 8 </AudioPlayerProvider> 9 ) 10}
useAudioPlayer
This is the main hook for controlling your audio instance.
Example:
1import React from "react" 2import { useAudioPlayer } from "react-use-audio-player" 3 4const AudioPlayer = ({ file }) => { 5 const { togglePlayPause, ready, loading, playing } = useAudioPlayer({ 6 src: file, 7 format: "mp3", 8 autoplay: false 9 }) 10 11 if (!ready && !loading) return <div>No audio to play</div> 12 if (loading) return <div>Loading audio</div> 13 14 return ( 15 <div> 16 <button onClick={togglePlayPause}>{playing ? "Pause" : "Play"}</button> 17 </div> 18 ) 19}
useAudioPlayer
optionally accepts some configuration as its only argument.
The available options closely mirror howler's options but differ in some areas.
src: string
The path to an audio file
format?: string
The format of the audio file. The format is infered from the file extension by default.
autoplay?: boolean
Read more here
html5?: boolean
Read more here
xhr?: Object
Read more here
useAudioPlayer
returns a single object containing the following members:
load: (config: object) => void
method to lazily load audio. It accepts the same configuration object that useAudioPlayer does.
loading: boolean
true if audio is being fetched
ready: boolean
true if the audio has been loaded and can be played
playing: boolean
true is the audio is currently playing
stopped: boolean
true if the audio has been stopped
ended: boolean
is true once the currently loaded audio finishes playing. This will be unset if you begin playing again or load a new sound.
error: Error
set when audio has failed to load
play: () => void
plays the loaded audio
pause: () => void
pauses the audio
togglePlayPause: () => void
convenient equivalent to alternating calls to play
and pause
stop: () => void
stops the audio, returning the position to 0
seek: (position: number) => number | undefined
sets the position of the audio to position (seconds)
mute: () => void
mutes the audio
volume: (value: number) => number
get/set the volume of the current sound. Volume values between 0.0 and 1.0
useAudioPosition
This hooks exposes the current position and duration of the audio instance as its playing in real time.
This data may be useful when animating a visualization for your audio like a seek bar.
A separate hook was created to manage this state in order to avoid many rerenders of components that don't need the live data feed.
For example a component that renders a play/pause button may use useAudioPlayer
but does not need to rerender every time the position of the playing audio changes.
1import React from "react" 2import { useAudioPosition } from "react-use-audio-player" 3 4const PlayBar = () => { 5 const { position, duration } = useAudioPosition({ highRefreshRate: true }) 6 const [percent, setPercent] = React.useState(0) 7 8 React.useEffect(() => { 9 setPercent((position / duration) * 100 || 0) 10 }, [position, duration]) 11 12 return <ProgressBar percentComplete={percent} /> 13}
(optional) config: { highRefreshRate: boolean }
highRefreshRate
will allow useAudioPosition to update state at a smooth 60fps rate
via the browser's requestAnimationFrame API. This is ideal for when you want smoother animations.useAudioPosition
returns an object containing the following members:
position: number
the current playback position of the audio in seconds
duration: number
the total length of the audio in seconds
seek
For convenience the seek
method from useAudioPlayer is also returned from this hook
To run the example applications follow the following steps:
git clone
the repositorycd useAudioPlayer/examples
yarn install
yarn start
The most basic npm release strategy is being followed for now. A good explanation can be found here.
Steps
yarn/npm version
(preversion script will ensure code is tested and built)yarn/npm publish
git push
& git push --tags
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/29 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
15 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More