Reputation: 2270
I am currently building an app in Next.js and I want to disable opening devtools. I found a nice package on npm - Disable-devtool - npm link but the problem is that nextjs keeps throwing me ReferenceError: navigator is not defined
. I tried to look into node_modules but didn't find any solution whatsoever, any help please?
Thank you ❤️
Upvotes: 1
Views: 3133
Reputation: 36
Try this:
if (
typeof window !== "undefined" &&
typeof window.navigator !== "undefined" &&
typeof navigator !== "undefined" &&
navigator.userAgent
) {
const disableDevtool = require("disable-devtool");
disableDevtool();
}
Upvotes: 2