Reference to `window` breaks SSR – fork with a fix is available

Hello! I sent an email to developer-advocates[at]sendbird[dot]com on the 8th but never got a reply, so I’m posting here instead:

We’ve been using @sendbird/uikit-react for a couple years inside of a custom React application, and we’re in the process of migrating to NextJS.

At the beginning, we were on version 3.3.7 and everything was working just fine. Then after upgrading to a newer React version, we started seeing a warning from React when rendering the SendBirdProvider component: “Support for defaultProps will be removed […]”.
So, I upgraded @sendbird/uikit-react to the latest version and that fixed the defaultProps issue. But now the latest version of the library (3.8.0) is causing server-side rendering in NextJS to fail, because SendBirdProvider uses the useOnlineStatus hook, which references the window object while setting the initial isOnline state, which is not defined in the NodeJS runtime. This raises an error and prevents SSR from working for the whole app.

I forked the library and made a small change with one commit, which I think should solve the issue. Then I went to create a pull request in your repository and it instructed me to send an email to developer-advocates[at]sendbird[dot]com instead. You can find my change in our fork here: Fix: Prevent "window is not defined" error during SSR in Node environ… · notice-co/sendbird-uikit-react@e393069 · GitHub

Could you merge the commit, or internally make a different commit that solves the problem, and release a patch version with the fix in the near future? I am happy to explain more about the issue or answer any questions that you have.

Thank you very much!