Using React UI Kit, you can integrate your Next.js application with CometChat.
Pre-requisites
First, if not already installed, add React and React DOM from your terminal using the following command.
Install CometChat SDK
Use the following command
Include React UI Kit
- Copy the cloned repository to your root folder
- Copy all the dependencies from package.json into your project’s package.js and install them
Build Chat component
Create chat.js file in your pages folder with the following code
Replace APP_ID, REGION, and AUTH_KEY with your CometChat App ID, Region, and in the below code.
Create consts.js file with ComeChat details in your root folder
Create CometChatNoSSR component in your root folder
Replace UID in the below code.
Import images in your Next.js project
Disable strict mode
If you are using React v18, make sure to disable strict mode in the next config to circumvent the re-render issue. Read more about the re-render issue here.