Skip to main content
The One-to-One Chat feature provides a streamlined direct messaging interface, making it ideal for support chats, dating apps, and private messaging platforms. This setup eliminates distractions by focusing solely on a dedicated chat window.

User Interface Preview

Key Components

  1. Chat Header – Displays recipient details and optional call/video call buttons.
  2. Message View – Shows real-time chat history.
  3. Message Input Box – Enables users to send messages, media, and reactions.

Step-by-Step Guide

Step 1: Implement the Chat Header

  • Display profile picture, name, and online status.
  • Add voice and video call buttons (optional).

Step 2: Build the Message View

  • Load chat history and real-time messages.
  • Ensure smooth scrolling and timestamp visibility.

Step 3: Add the Message Composer

  • Include a text input field.
  • Support media uploads, file attachments, emojis, and reactions.

Implementation

Now we will create the CometChatNoSSR.tsx & CometChatNoSSR.css files. Here, we will initialize the CometChat UI Kit, log in a user, and build the messaging experience using CometChatMessageHeader, CometChatMessageList, and CometChatMessageComposer components.
CometChatNoSSR.tsx
In the code snippet above, ensure you select either a user or a group based on your chat requirement. You can also determine this dynamically depending on the conversation type.

Fetching a User (One-on-One Chat)

Fetching a Group (Group Chat)

Step 4: Disable SSR and Render the CometChat Component

Create a file CometChat.tsx inside the routes folder:
Now, create a route for CometChat in your routes file:
Why disable SSR? CometChat UI Kit Builder relies on browser APIs such as window, document, and WebSockets. Since React Router renders on the server by default, disabling SSR for this component prevents runtime errors.

Step 5: Update App CSS

Next, add the following styles to app.css to ensure CometChat UI Kit is properly styled.
app.css

Step 6: Run Your Application

  1. Start the development server
  2. Verify the chat interface
  • In your browser, navigate to the /chat route (e.g., http://localhost:3000/chat).
  • Confirm that the chat experience loads as expected.

Next Steps

Enhance the User Experience