e3ntity/react-sounds
Sobre
Play sounds in React. Comes with hundreds of built-in effects, or use your own audio files.
Desenvolvimento web e de aplicativosCrescimento medido de estrelas
- em 24 h
- 0
- em 7 dias
- -1
- em 15 dias
- -1
- em 1 mês
- Coletando histórico
Variações líquidas em períodos sobrepostos, não totais diários. Medições ausentes ficam em branco. Estrelas indicam interesse, não qualidade.
README.md
Originalreact-sounds 🔊
Hundreds of ready-to-play sound effects for your React applications
Add delight to your UI with just a few lines of code
Demo • Documentation • Sound Explorer • More Sounds
✨ Why react-sounds?
- 🪶 Lightweight: Only loads JS wrappers, audio files stay on CDN until needed
- 🏗️ Lazy Loading: Sounds are fetched only when they're used
- 📦 Offline Support: Download sounds for self-hosting with the included CLI
- 🎯 Simple API: Intuitive hooks and components
- 🔊 Extensive Library: Hundreds of categorized sounds (UI, notification, game)
How does react-sounds compare?
| react-sounds | use-sound | howler.js | |
|---|---|---|---|
| Built-in sounds | 72+ | None | None |
| React hooks & components | Yes | Hooks | None |
| Bundle size (gzipped) | ~5 KB + howler, sounds load from a CDN when used | ~1 KB + howler (loaded lazily) | ~10 KB |
| TypeScript | Built-in | Built-in | @types |
| Last release | Nov 2026 | Feb 2025 | Sep 2023 |
react-sounds wraps howler.js and adds a curated sound library, React components, and zero-config CDN delivery. use-sound and howler.js are great standalone options if you bring your own audio files.
Coming from use-sound? See use-sound vs react-sounds for a detailed comparison and how to switch.
🚀 Quick Start
npm install react-sounds howler
# or
yarn add react-sounds howler
import { useSound } from 'react-sounds';
function Button() {
const { play } = useSound('ui/button_soft');
return (
<button onClick={() => play()}>
Click Me
</button>
);
}
Your own sounds and sound packs
Any MP3 URL works (cross-origin files need CORS headers):
const { play } = useSound('https://cdn.example.com/sounds/whoosh.mp3');
Or add a sound pack, a manifest.json listing MP3 files by name. The CLI writes the manifest and TypeScript types into your app:
npx react-sounds-cli add https://openfoley.com/c/ui-sounds # add --download to copy the files into public/
import uiSounds from './sounds/ui-sounds.json';
<SoundProvider packs={[uiSounds]}>...</SoundProvider> // or registerSounds(uiSounds)
const { play } = useSound('ui-sounds/bright-success-chime'); // typed and autocompleted
Turn a folder of your own MP3s into a pack with npx react-sounds-cli pack ./my-sounds.
🧰 API at a Glance
| What it does | |
|---|---|
useSound(name, options) |
Returns play, stop, pause, resume, isPlaying and isLoaded for a sound |
useSoundOnChange(name, value) |
Plays a sound whenever value changes |
useSoundEnabled() |
App-wide mute toggle, remembered in localStorage |
<Sound name="..." trigger="mount" /> |
Plays a sound when it mounts or unmounts, without a hook |
<SoundButton sound="..."> |
A button that plays a sound on click |
<SoundProvider preload={[...]} packs={[...]}> |
Preloads sounds and registers sound packs |
registerSounds(pack), preloadSounds(names) |
The same outside of React |
Every option is in the documentation.
🎨 More Sounds
Need a sound that isn't built in? openfoley is an open library of CC0 sound effects and sound packs that work with react-sounds out of the box. You can also generate new sounds there with AI.
Using an AI coding agent? Add the openfoley MCP server and just ask for the sound you need, e.g. "add a soft click to the buttons":
claude mcp add --transport http openfoley https://openfoley.com/mcp
Searching works without an account. To let your agent generate sounds and build sound packs, add an API token.
📚 Documentation
For complete documentation including advanced usage, visit reactsounds.com/docs
Guides:
- How to play sounds in React: the Audio element, the Web Audio API and libraries compared
- Using Howler.js in React: a small hook that loads once and cleans up after itself
- use-sound vs react-sounds: when to pick which, and how to switch
🎮 Live Demo
Try the interactive demo at reactsounds.com
🔍 Explore All Sounds
Browse and play all available sounds at reactsounds.com/sounds
💻 Browser Support
Works in all modern browsers (Chrome, Firefox, Safari, Edge). Sounds play through the Web Audio API, with an HTML5 Audio fallback from howler.js.
📄 License
MIT © Lukas Schneider
Explore projetos relacionados
Carregando…