alibaba / ChatUI

The UI design language and React library for Conversational UI
https://chatui.io
MIT License
2.62k stars 278 forks source link

Next JS support #47

Closed nyousefzai closed 3 years ago

nyousefzai commented 3 years ago

What problem does this feature solve? (这个功能解决了什么问题) When using with next js project you get window not defined! node_modules/@chatui/core/lib/utils/canUse.js (30:30) Screen Shot 2021-07-22 at 12 10 00 PM

Describe the solution you'd like (描述您想要的解决方案) it should work with next js

What does the proposed API look like? (你期望的 API 是怎样的)

nyousefzai commented 3 years ago

solution:

since nextjs renders component on server side, it needs to turn off the ssr mode

anyone who runs to the same issue please use import dynamic from "next/dynamic" and ssr:false hope this helps other foks!

huanlirui commented 1 year ago

solution:

since nextjs renders component on server side, it needs to turn off the ssr mode

anyone who runs to the same issue please use import dynamic from "next/dynamic" and ssr:false hope this helps other foks!

hello ,how to import chatui/core ? please give me a example

import Chat, { Bubble, useMessages } from "@chatui/core";

if use this code , get window not defined!

huanlirui commented 1 year ago

solution :

take your component out of pages folder

use next/dynamic to import this component

like

const Chat = dynamic(
  () => {
    return import("../../components/chat");
  },
  { ssr: false }
);