T
TanStack2mo ago
adverse-sapphire

How to handle static audio?

In an app where I have static mp3 audio files, where should I store them and how do I import them?
1 Reply
extended-salmon
extended-salmon2mo ago
I think you can store the mp3 file in an asset folder under src and import it like that:
import sound from '~/assets/sound.mp3'

// jsx
<audio src={sound} controls />
import sound from '~/assets/sound.mp3'

// jsx
<audio src={sound} controls />
or in a public folder and use it directly:
<audio src="/sound.mp3" controls />
<audio src="/sound.mp3" controls />

Did you find this page helpful?