How would I write data to an Audio File?

So I’ve been trying to make a DAW in the browser and I’ve got everything done except for exporting files. How would I go about writing data for an audio file?

I’ve tried utilizing the MediaRecorder API. I was expecting to be able to write data like that, but what actually happened was that it prompted me to use my microphone which is not what I was expecting.