Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: navigator is not defined #32

Open
doverradio opened this issue Apr 24, 2020 · 1 comment
Open

ReferenceError: navigator is not defined #32

doverradio opened this issue Apr 24, 2020 · 1 comment

Comments

@doverradio
Copy link

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
@ozdemiremrah
Copy link

ozdemiremrah commented Nov 10, 2021

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 }
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants