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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sonardigital/audio-notifications

v1.0.2

Published

Lightweight audio notifications package for React applications

Readme

@sonardigital/audio-notifier

A React package for safely using howler.js for audio notifications with context and hooks.

Features

  • 🔊 Safe wrapper around howler.js
  • 🎵 Register and manage multiple sounds
  • 🔇 Global mute/unmute control
  • 🎚️ Global and per-sound volume control
  • 📊 Sound status tracking (loading, playing, paused, stopped, error)
  • ⚛️ React Context + Hook pattern
  • 🧹 Automatic cleanup on unmount

Installation

npm install @sonardigital/audio-notifier howler

Usage

With Provider (Recommended)

import { AudioNotifierProvider, useAudioNotifierContext } from '@sonardigital/audio-notifier';

// Wrap your app
function App() {
	return (
		<AudioNotifierProvider initialVolume={0.8} initialMuted={false}>
			<YourApp />
		</AudioNotifierProvider>
	);
}

// Use in any component
function NotificationButton() {
	const { registerSound, play, isMuted, setMuted } = useAudioNotifierContext();

	useEffect(() => {
		registerSound('notification', '/sounds/notification.mp3');
		registerSound('success', '/sounds/success.mp3', { volume: 0.5 });
	}, [registerSound]);

	return (
		<div>
			<button onClick={() => play('notification')}>Play Notification</button>
			<button onClick={() => play('success')}>Play Success</button>
			<button onClick={() => setMuted(!isMuted)}>{isMuted ? 'Unmute' : 'Mute'}</button>
		</div>
	);
}

Standalone Hook

import { useAudioNotifier } from '@sonardigital/audio-notifier';

function MyComponent() {
	const {
		registerSound,
		unregisterSound,
		play,
		pause,
		stop,
		isMuted,
		setMuted,
		volume,
		setVolume,
		getSoundStatus,
		isPlaying,
	} = useAudioNotifier({ initialVolume: 1, initialMuted: false });

	useEffect(() => {
		registerSound('alert', ['/sounds/alert.mp3', '/sounds/alert.ogg']);
		return () => unregisterSound('alert');
	}, []);

	return (
		<div>
			<button onClick={() => play('alert')}>Play Alert</button>
			<button onClick={() => stop('alert')}>Stop</button>
			<input
				type="range"
				min="0"
				max="1"
				step="0.1"
				value={volume}
				onChange={(e) => setVolume(Number(e.target.value))}
			/>
		</div>
	);
}

API

AudioNotifierContextType

| Property | Type | Description | | ----------------- | ------------------------------------------ | ------------------------------- | | sounds | Map<string, AudioSound> | Map of registered sounds | | isMuted | boolean | Whether audio is globally muted | | volume | number | Global volume (0-1) | | play | (soundId: string) => number \| null | Play a sound by ID | | pause | (soundId: string) => void | Pause a sound by ID | | stop | (soundId: string) => void | Stop a sound by ID | | registerSound | (id, src, options?) => void | Register a new sound | | unregisterSound | (id: string) => void | Unregister a sound | | setMuted | (muted: boolean) => void | Set global mute state | | setVolume | (volume: number) => void | Set global volume | | getSoundStatus | (soundId: string) => AudioStatus \| null | Get sound status | | isPlaying | (soundId: string) => boolean | Check if sound is playing |

HowlOptions

| Option | Type | Default | Description | | --------- | ----------------------- | ------- | ----------------------- | | volume | number | 1 | Volume (0-1) | | loop | boolean | false | Whether to loop | | rate | number | 1 | Playback rate (0.5-4) | | preload | boolean \| 'metadata' | true | Whether to preload | | html5 | boolean | false | Use HTML5 Audio | | sprite | object | - | Audio sprite definition |

AudioStatus

'idle' | 'loading' | 'playing' | 'paused' | 'stopped' | 'error'

Provider Props

| Prop | Type | Default | Description | | --------------- | --------- | ------- | --------------------------- | | initialVolume | number | 1 | Initial global volume (0-1) | | initialMuted | boolean | false | Initial muted state |

Browser Support

Howler.js supports all modern browsers and handles codec fallbacks automatically. Provide multiple audio formats for best compatibility.