I've installed JSEncrypt npm package for asymmetric encryption. But when I run the project I get the below error
Server Error ReferenceError: window is not defined
I even tried to dynamically load the JSEncrypt.min.js file in the project.
Can some one help resolving this?
Thats because
windowis not defined while Server Side Rendering.Importing the component (where you are including JSEncrypt) with
next/dynamicand SSR set to false should fix the issue.Ex.