crisp-im / crisp-sdk-web

:package: Include the Crisp chat widget from using frameworks such as React, VueJS, Angular...
https://www.npmjs.com/package/crisp-sdk-web
MIT License
40 stars 13 forks source link

"Document is not defined" error on Next.JS when Implementing the library #10

Closed ReyMga closed 1 year ago

ReyMga commented 1 year ago

I installed the crisp-sdk-web in a Next.js project, but I am getting an error: "document is not defined".

image

Note: With a common react project (create-react-app) it works OK.

ReyMga commented 1 year ago

It works for next js, it was a configuration error from my side. Thank you!

baptistejamin commented 1 year ago

Hi, our agents are offline at the moment. Please leave a message and we will get back to you as soon as possible.

baptistejamin commented 1 year ago

Hello!

How did you solve the problem?

loiclouvet commented 1 year ago

Hello!

How did you solve the problem?

@baptistejamin Might be related to server side rendering for Nextjs. Crisp has to be loaded client side only. A solution could be to put the configure or load method inside a useEffect.