react-audio-recorder
react-audio-recorder copied to clipboard
ReferenceError: navigator is not defined
Hello,
I came across your library and wanted to test drive it in my app. However, after installing and running, I got this error:
Module../node_modules/react-audio-recorder/dist/getUserMedia.js
./node_modules/react-audio-recorder/dist/getUserMedia.js:1
> 1 | export default navigator.mediaDevices ?
2 | navigator.mediaDevices.getUserMedia :
3 | (navigator.getUserMedia ||
4 | navigator.webkitGetUserMedia ||```
Is there a solution for this?
I'm running it in next.js
Hello there,
Next.js runs all import files server side. You can use dynamic import to get around this problem. Dynamic Import - Next.js
For example:
import dynamic from 'next/dynamic'
const AudioRecorder = dynamic(
() => import('react-audio-recorder'),
{ ssr: false }
)