Problem Description
I'm trying to play an MP3 audio file in my Next.js 15 application, but the audio files in the public/audio/ directory are not being served. When I check the browser's developer tools, the audio folder is not generated/served at all, although
Environment
- Next.js: 15.3.5
- Node.js: 22.14.0
- Browser: Edge (latest)
Project Structure
sample-project/
├── public/
│ └── audio/
│ └── sample.mp3 (38KB file exists)
├── app/
│ └── todolist/
│ └── page.tsx
│ └── todoList.tsx
└── package.json
Code
todoList.tsx (relevant part):
const playDeleteSound = async () => {
try {
const audio = new Audio('/audio/sample.mp3');
await audio.play();
} catch (error) {
console.log('Audio playback error:', error);
}
};
What I've Tried
- Direct URL access: Accessing
http://localhost:3000/audio/sample.mp3returns 302 - Browser dev tools: No
audiofolder appears in the Sources tab
Expected Behavior
The MP3 file should be served as a static asset from the public directory, accessible at /audio/sample.mp3, just like images are served from public/images/.
Actual Behavior
- 302 when accessing the audio file URL directly
- No audio folder visible in developer tools
new Audio()fails to load the file
Questions
- Is there a specific configuration needed to serve audio files from the
publicdirectory? - Are there any known limitations with static audio assets?
- What's the recommended approach for handling audio files in Next.js 15?
Additional Notes
- Images in
public/images/work perfectly fine - Designating a certain URL of mp3 file online as the parameter of Audio instead of '/audio/sample.mp3' also works perfectly fine
- File certainly exists and no mistakes with its file path (38KB MP3 file)
Any help would be greatly appreciated!

Audioapproach, I would try to utilize this function within auseEffect. Do you get the error caught logged in the console? I believe the web audio API can, for the most part, only be utilized on the client side, so ensure this is within'use client'as well.