Next.js Discord

Discord Forum

Audio Worklet

Unanswered
Giant panda posted this in #help-forum
Open in Discord
Giant pandaOP
Is there a best practice for (or is even possible to) having Audio Worklets in Nextjs v13? I'm not sure where the code for the worklet should be placed for the following code to run properly:

 const context = new AudioContext();
 await context.audioWorklet.addModule("/volume-meter-processor.js");


Where should the file containing the Worklet code be placed and how it should be executed?

1 Reply

Since it is a browser API, you have to put it in a useEffect (in client component)