Redux Sounds is a Redux middleware designed to integrate sound effects into Redux applications by dispatching actions. It acts as a bridge between your Redux store and the Howler.js audio library, allowing developers to play sounds declaratively. The current stable version is 3.3.2. This package has a moderate release cadence, with significant updates historically aligning with major Howler.js versions and adding features like dynamic sound loading, playlists, and sprite support. Its key differentiator is the declarative Redux-first approach to sound management, abstracting away direct Howler.js API calls for common use cases, making it easier to manage sound logic within a predictable application state.
npm install redux-soundsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates setting up `redux-sounds` with a Redux store, defining `soundData`, and dispatching actions that trigger sound playback via the middleware.
Update `action.meta.sound` from a string like `'jumps.lowJump'` to an object like `{ fade: ['jumps.lowJump', 0, 1, 2] }` or `{ play: 'soundId' }` to use Howler methods explicitly.Change any `urls` property in your `soundData` configuration objects to `src` (e.g., `{ src: ['path/to/sound.mp3'] }`).Install `howler` via `npm install howler` or `yarn add howler` and ensure `Howl` is imported and passed: `createSoundMiddleware(soundData, Howl)`.
Refer to the documentation for sprite configuration, e.g., `{ urls: ['path/to/sprite.mp3'], sprite: { soundA: [0, 1000], soundB: [1500, 500] } }`.Ensure `npm install howler` is run and `createSoundMiddleware(soundData, Howl)` is correctly configured, importing `Howl` from `howler`.
Add a `meta` object to your action with a `sound` property, for example: `dispatch({ type: 'PLAY_BEEP', meta: { sound: 'beep' } })`.Double-check all sound paths in `soundData`. Ensure files exist at the specified locations and are accessible. Consider browser autoplay policies for initial sounds.