Getting ReferenceError: window is not defined for Next JS project

Description
Can’t seem to init the ZoomMtg library in my Next JS project. When i try to used it will throw the error below

Browser Console Error
ReferenceError: window is not defined

Which Web Meeting SDK version?
v2.0.1

Meeting SDK Code Snippets
Error starts immediately after trying to use th ZoomMtg

import { ZoomMtg } from "@zoomus/websdk";

 ZoomMtg.setZoomJSLib("https://source.zoom.us/2.0.1/lib", "/av");
 ZoomMtg.preLoadWasm();
 ZoomMtg.prepareJssdk();

Screenshots

Device (please complete the following information):

  • Device: [e.g. Macbook Pro]
  • OS: [e.g. macOS 11]
  • Browser: Chrome
  • Browser Version [e.g. 88.0.4324.150 (Official Build) (x86_64)]

Additional context

Hey @lavaxDev,

Thank you for reaching out to the Zoom Developer Forum. This is a side-effect of using hybrid or server-side rendering.

In your code, you’ll want to check if you are rendering on the server or on the client:

I hope that helps! Let me know if you have any questions.

Thanks,
Max

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.