Nextjs PizZip Library "window is not defined" error

34 Views Asked by At

Im using PizZip library in my Nextjs project to use with Docxtemplater. But I got an error: error

I checked the library file and found it uses window object. I guess it tries to access window object before the page load. (at the prerendering). How can I solve that problem?

I havent tried something yet. Also im getting the same error about window object at the build time.

SOLVED:

I have solved the problem just now. I removed the component (my modal that uses PizZip library to use Docxtemplater) from layout.js file and I moved it to a client component. It works rn. Thanks for your answers.

0

There are 0 best solutions below