├── .DS_Store ├── .gitignore ├── LICENSE ├── README.md ├── bin └── react-sounds-cli.js ├── package-lock.json ├── package.json ├── public └── sounds │ └── silence.mp3 ├── rollup.config.js ├── scripts ├── generate-manifest.js ├── generate-types.js └── upload-to-cdn.js ├── sounds ├── .DS_Store ├── ambient │ ├── .DS_Store │ ├── campfire.mp3 │ ├── heartbeat.mp3 │ ├── rain.mp3 │ ├── water_stream.mp3 │ └── wind.mp3 ├── arcade │ ├── .DS_Store │ ├── coin.mp3 │ ├── coin_bling.mp3 │ ├── jump.mp3 │ ├── level_down.mp3 │ ├── level_up.mp3 │ ├── power_down.mp3 │ ├── power_up.mp3 │ └── upgrade.mp3 ├── game │ ├── .DS_Store │ ├── coin.mp3 │ ├── hit.mp3 │ ├── miss.mp3 │ ├── portal_closing.mp3 │ ├── portal_opening.mp3 │ └── void.mp3 ├── misc │ ├── .DS_Store │ └── silence.mp3 ├── notification │ ├── .DS_Store │ ├── completed.mp3 │ ├── error.mp3 │ ├── info.mp3 │ ├── message.mp3 │ ├── notification.mp3 │ ├── popup.mp3 │ ├── reminder.mp3 │ ├── success.mp3 │ └── warning.mp3 ├── system │ ├── .DS_Store │ ├── boot_down.mp3 │ ├── boot_up.mp3 │ ├── device_connect.mp3 │ ├── device_disconnect.mp3 │ ├── lock.mp3 │ ├── screenshot.mp3 │ └── trash.mp3 └── ui │ ├── .DS_Store │ ├── blocked.mp3 │ ├── button_hard.mp3 │ ├── button_hard_double.mp3 │ ├── button_medium.mp3 │ ├── button_soft.mp3 │ ├── button_soft_double.mp3 │ ├── button_squishy.mp3 │ ├── buzz.mp3 │ ├── buzz_deep.mp3 │ ├── buzz_long.mp3 │ ├── copy.mp3 │ ├── input_blur.mp3 │ ├── input_focus.mp3 │ ├── item_deselect.mp3 │ ├── item_select.mp3 │ ├── keystroke_hard.mp3 │ ├── keystroke_medium.mp3 │ ├── keystroke_soft.mp3 │ ├── panel_collapse.mp3 │ ├── panel_expand.mp3 │ ├── pop_close.mp3 │ ├── pop_open.mp3 │ ├── popup_close.mp3 │ ├── popup_open.mp3 │ ├── radio_select.mp3 │ ├── send.mp3 │ ├── submit.mp3 │ ├── success_bling.mp3 │ ├── success_blip.mp3 │ ├── success_chime.mp3 │ ├── tab_close.mp3 │ ├── tab_open.mp3 │ ├── toggle_off.mp3 │ ├── toggle_on.mp3 │ ├── window_close.mp3 │ └── window_open.mp3 ├── src ├── components.tsx ├── hooks.ts ├── index.ts ├── manifest.json ├── runtime.ts ├── types.ts └── utils.ts ├── tsconfig.json └── website ├── .gitignore ├── README.md ├── eslint.config.js ├── index.html ├── package-lock.json ├── package.json ├── public └── favicon.svg ├── src ├── App.css ├── App.tsx ├── assets │ ├── music.mp3 │ └── react.svg ├── components │ ├── AdvancedSoundDemo.tsx │ ├── CodeBlock.tsx │ ├── FeatureCard.tsx │ ├── Footer.tsx │ ├── Header.tsx │ └── SoundSelector.tsx ├── declarations.d.ts ├── index.css ├── main.tsx ├── manifest.json ├── pages │ ├── DocumentationPage.tsx │ ├── HomePage.tsx │ └── SoundLibraryPage.tsx └── utils │ └── cn.ts ├── tailwind.config.js ├── tsconfig.json ├── tsconfig.node.json └── vite.config.js /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aediliclabs/react-sounds/47051a762479cf0b639e3d48146de3b43ab0001c/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Optional stylelint cache 58 | .stylelintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variable files 76 | .env 77 | .env.development.local 78 | .env.test.local 79 | .env.production.local 80 | .env.local 81 | 82 | # parcel-bundler cache (https://parceljs.org/) 83 | .cache 84 | .parcel-cache 85 | 86 | # Next.js build output 87 | .next 88 | out 89 | 90 | # Nuxt.js build / generate output 91 | .nuxt 92 | dist 93 | 94 | # Gatsby files 95 | .cache/ 96 | # Comment in the public line in if your project uses Gatsby and not Next.js 97 | # https://nextjs.org/blog/next-9-1#public-directory-support 98 | # public 99 | 100 | # vuepress build output 101 | .vuepress/dist 102 | 103 | # vuepress v2.x temp and cache directory 104 | .temp 105 | .cache 106 | 107 | # vitepress build output 108 | **/.vitepress/dist 109 | 110 | # vitepress cache directory 111 | **/.vitepress/cache 112 | 113 | # Docusaurus cache and generated files 114 | .docusaurus 115 | 116 | # Serverless directories 117 | .serverless/ 118 | 119 | # FuseBox cache 120 | .fusebox/ 121 | 122 | # DynamoDB Local files 123 | .dynamodb/ 124 | 125 | # TernJS port file 126 | .tern-port 127 | 128 | # Stores VSCode versions used for testing VSCode extensions 129 | .vscode-test 130 | 131 | # yarn v2 132 | .yarn/cache 133 | .yarn/unplugged 134 | .yarn/build-state.yml 135 | .yarn/install-state.gz 136 | .pnp.* 137 | 138 | # custom 139 | .cursor/ 140 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Aedilic Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-sounds 🔊 2 | 3 |
4 |
5 |
6 |
7 |
10 | Hundreds of ready-to-play sound effects for your React applications
11 | Add delight to your UI with just a few lines of code
12 |
15 | Demo • 16 | Documentation • 17 | Sound Explorer 18 |
19 | 20 | ## ✨ Why react-sounds? 21 | 22 | - 🪶 **Lightweight**: Only loads JS wrappers, audio files stay on CDN until needed 23 | - 🔄 **Lazy Loading**: Sounds are fetched only when they're used 24 | - 📦 **Offline Support**: Download sounds for self-hosting with the included CLI 25 | - 🎯 **Simple API**: Intuitive hooks and components 26 | - 🔊 **Extensive Library**: Hundreds of categorized sounds (UI, notification, game) 27 | 28 | ## 🚀 Quick Start 29 | 30 | ```bash 31 | npm install react-sounds howler 32 | # or 33 | yarn add react-sounds howler 34 | ``` 35 | 36 | ```tsx 37 | import { useSound } from 'react-sounds'; 38 | 39 | function Button() { 40 | const { play } = useSound('ui/button_1'); 41 | 42 | return ( 43 | 46 | ); 47 | } 48 | ``` 49 | 50 | ## 📚 Documentation 51 | 52 | For complete documentation including advanced usage, visit [reactsounds.com/docs](https://www.reactsounds.com/docs) 53 | 54 | ## 🎮 Live Demo 55 | 56 | Try the interactive demo at [reactsounds.com](https://www.reactsounds.com) 57 | 58 | ## 🔍 Explore All Sounds 59 | 60 | Browse and play all available sounds at [reactsounds.com/sounds](https://www.reactsounds.com/sounds) 61 | 62 | ## 💻 Browser Support 63 | 64 | Works in all modern browsers that support the Web Audio API (Chrome, Firefox, Safari, Edge) 65 | 66 | ## 📄 License 67 | 68 | MIT © Aedilic Inc. 69 | 70 | --- 71 | 72 |73 | Made with ♥ by Aedilic Inc 74 |
75 | -------------------------------------------------------------------------------- /bin/react-sounds-cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const fs = require("fs"); 4 | const path = require("path"); 5 | const https = require("https"); 6 | 7 | // Load the manifest 8 | const manifestPath = path.join(__dirname, "../dist/manifest.json"); 9 | let manifest; 10 | 11 | try { 12 | manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8")); 13 | } catch (err) { 14 | console.error("Error loading manifest:", err.message); 15 | process.exit(1); 16 | } 17 | 18 | // Get the CDN base URL 19 | const cdnBaseUrl = process.env.REACT_SOUNDS_CDN || "https://reacticons.sfo3.cdn.digitaloceanspaces.com/v1"; 20 | 21 | // Parse command line arguments 22 | const args = process.argv.slice(2); 23 | let command = args[0]; 24 | let soundNames = []; 25 | let outputDir = "./public/sounds"; 26 | 27 | if (command === "pick") { 28 | soundNames = args.slice(1).filter((arg) => !arg.startsWith("--")); 29 | 30 | // Check for output directory option 31 | const outputOption = args.find((arg) => arg.startsWith("--output=")); 32 | if (outputOption) { 33 | outputDir = outputOption.split("=")[1]; 34 | } else { 35 | const outputIndex = args.indexOf("--output"); 36 | if (outputIndex !== -1 && args[outputIndex + 1]) { 37 | outputDir = args[outputIndex + 1]; 38 | } 39 | } 40 | 41 | if (soundNames.length === 0) { 42 | console.error("Please specify at least one sound to pick."); 43 | console.log("Usage: npx react-sounds-cli pickClick the buttons to hear different sound effects.
46 |Try adjusting these parameters before playing the sound.
95 | 96 |{category.description}
203 |
26 | {children}
27 |
28 | );
29 | };
30 |
31 | export default CodeBlock;
32 |
--------------------------------------------------------------------------------
/website/src/components/FeatureCard.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | interface FeatureCardProps {
4 | title: string;
5 | description: string;
6 | icon?: string;
7 | }
8 |
9 | const FeatureCard: React.FC{description}
15 |
49 | react-sounds
provides a library of
50 | ready-to-play sound effects for your React applications, designed to be lightweight, easy to use, and
51 | flexible. It's built on top of Howler.js and provides a simple API for playing sounds in your React apps.
52 |
Install the library and its peer dependency, Howler.js:
90 |96 | Note:{" "} 97 | 103 | Howler.js 104 | {" "} 105 | is a required peer dependency. 106 |
107 |useSound
Hook
115 |
117 | The useSound
hook is the primary way to
118 | interact with sounds.
119 |
You can use your own custom sound files by requiring them directly:
136 |playSound
154 | For simple, one-off sound playback without needing state or controls.
156 |SoundProvider
182 |
184 | For best results, wrap your application with the{" "}
185 | SoundProvider
component. This allows control
186 | of sound enabled state, preloads sounds, and establishes the sound context.
187 |
useSound
Hook
213 |
215 | The useSound
hook provides full control over
216 | sound playback. It works with both built-in sound names and custom sound files.
217 |
For declarative sound playback within your components.
254 |Additional hooks for specific sound use cases.
293 |330 | Configure where built-in sound files are loaded from. Note: This doesn't affect custom sound files that you 331 | import directly. 332 |
333 |345 | Globally enable or disable all sounds. The setting is automatically persisted in localStorage. 346 |
347 |Preload sounds to ensure they are ready for immediate playback.
362 |Customize sound playback with various options.
374 |406 | Use the CLI tool to download sounds for offline use or explore available sounds. 407 |
408 |424 | react-sounds provides TypeScript definitions for all exported functions, hooks, components, and types. 425 |
426 | 427 |Sounds can be either built-in sound names or custom imported sound files.
429 |
457 | Type definition for what useSound
hook
458 | returns.
459 |
103 | react-sounds
provides a library of ready-to-play
104 | sound effects with a simple API, lazy loading, and offline support.
105 |
106 |
120 | MIT License
121 |
122 |
Check out the documentation or install the library now.
169 |
219 | {soundKey}
220 |
221 | 379 | Showing {paginatedSounds.length} of {filteredSounds.length} sounds 380 | {selectedCategory && ( 381 | 388 | {selectedCategory[0].toUpperCase() + selectedCategory.slice(1)} 389 | 390 | )} 391 |
392 | 393 | {/* Pagination controls */} 394 | {totalPages > 1 && ( 395 |Try adjusting your search or filter to find what you're looking for.
458 |