cahilfoley/react-snowfall

ReferenceError: window is not defined

Closed this issue · 1 comments

Hi there, thanks for your lib.

We are facing the following error on build:

Screen Shot 2020-11-11 at 6 03 58 PM

we are using nextjs:
"next": "^9.4.0"

Window object isn't available when rendering on the server. You have to load the module only on the client side, either in useEffect or like below (note the prop disabling ssr):

import dynamic from "next/dynamic";
const Snowfall = dynamic(() => import("react-snowfall"), { ssr: false });