Prerequisites
Before installing Soundcn, ensure your project meets these requirements:TypeScript (Recommended)
While not strictly required, TypeScript provides full type safety and IntelliSense for sound assets and options.
Installation Methods
Method 1: Install Individual Sounds
The recommended way to use Soundcn is to install individual sounds as needed:Browse the Sound Library
Visit soundcn.xyz to browse and preview the 700+ available sounds. Use filters to find sounds by category, duration, or search terms.
Copy Installation Command
Click on any sound to view its details, then copy the installation command:This command will:
- Install the sound file in
src/sounds/click-soft/ - Install the
useSoundhook insrc/hooks/ - Install supporting utilities in
src/lib/
The first time you install a sound, the CLI will also install the necessary dependencies (
useSound hook, type definitions, and the sound engine).Method 2: Install the Hook Only
If you want to set up the infrastructure without installing specific sounds:src/hooks/use-sound.ts- React hook for sound playbacksrc/lib/sound-engine.ts- Core Web Audio API utilitiessrc/lib/sound-types.ts- TypeScript type definitions
What Gets Installed
When you install a sound, the following files are added to your project:Sound File
useSound Hook
Sound Engine
- Audio context management
- Audio buffer caching
- Base64 decoding and audio data processing
- Framework-agnostic
playSound()function
Verify Installation
After installation, verify the files were created:Project Structure
After installing several sounds, your project structure will look like:Installing Multiple Sounds
You can install multiple sounds in sequence:The hook and library files are only installed once. Subsequent sound installations only add the new sound files.
Framework-Specific Notes
Next.js
Soundcn works with both the App Router and Pages Router:- App Router: Mark components using
useSoundwith"use client"directive - Pages Router: Works out of the box
- Server Components: Use the
playSound()function in client components
Vite
Works seamlessly with Vite’s default React setup. Ensure path aliases are configured invite.config.ts:
Create React App
Configure path aliases usingcraco or react-app-rewired. Alternatively, use relative imports:
Troubleshooting
Module not found: Can't resolve '@/hooks/use-sound'
Module not found: Can't resolve '@/hooks/use-sound'
This usually means path aliases aren’t configured. Check your For Vite, also configure
tsconfig.json:vite.config.ts (see Framework-Specific Notes above).Audio doesn't play on mobile Safari
Audio doesn't play on mobile Safari
Mobile browsers require user interaction before playing audio. Ensure the first sound is triggered by a user action (click, tap):
TypeScript errors with SoundAsset
TypeScript errors with SoundAsset
Make sure TypeScript can find the type definitions:If errors persist, restart your TypeScript server in VS Code:
- Cmd/Ctrl + Shift + P
- “TypeScript: Restart TS Server”
shadcn CLI not found
shadcn CLI not found
The shadcn CLI should work with
npx without installation. If it fails:Next Steps
Now that Soundcn is installed:- Quick Start - Build your first sound-enabled component
- Browse Sounds - Explore the full library
