Documentation Index
Fetch the complete documentation index at: https://cometchat-22654f5b-react-uikit-v7.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
SSR Hydration Errors
Symptom
You see a React hydration mismatch error in the console when rendering your app with a server-side rendering framework (Next.js, Remix, Astro SSR):Root Cause
CometChatProvider uses browser-only APIs (WebSocket connections, window, localStorage) during initialization. When the component renders on the server, it produces different output than the client, causing a hydration mismatch.
Solution
Mark the component boundary containingCometChatProvider as client-only. In Next.js App Router, add the 'use client' directive at the top of the file:
client:only="react" directive on the component that wraps CometChatProvider:
CometChatProvider only renders in the browser where its required APIs are available.
React StrictMode Double-Mount
Symptom
You notice duplicate SDK event listeners firing, causing messages to appear twice or callbacks triggering multiple times during development.Root Cause
React StrictMode intentionally mounts, unmounts, and remounts components in development to help detect side effects that aren’t properly cleaned up. If SDK listeners aren’t cleaned up on unmount, the remount adds a second listener.Solution
All v7 hooks handle cleanup automatically. If you’re writing custom hooks that attach SDK listeners, always return a cleanup function fromuseEffect:
- Use
useId()for unique listener IDs — it’s stable across StrictMode remounts within the same component instance. - Always remove listeners in the cleanup function returned from
useEffect. - The built-in
useSDKEventshook already handles this correctly.
SDK Initialization Failures
Symptom
The chat UI shows an error state or nothing renders. The console displays:Root Cause
Invalid credentials: TheappId, region, or authKey passed to CometChatProvider are incorrect, expired, or belong to a different environment (e.g., using production credentials in a development build).
Network issues: The client cannot reach CometChat’s servers due to network restrictions, firewall rules, or the CometChat service being temporarily unavailable.
Solution
Verify your credentials match your CometChat dashboard and use theonError callback to surface initialization issues:
- Confirm
appIdandregionmatch the values shown in your CometChat Dashboard - Ensure credentials are for the correct environment (development vs. production)
- Check that your network allows outbound WebSocket connections
- Verify the
authKeyhas not been rotated since you last copied it
Theme Not Applying
Symptom
Components render with default styling and ignore the theme you’ve configured. Colors, fonts, or spacing don’t match your custom theme.Root Cause
The theme system relies on two things working together:- The CSS styles file being imported (provides the CSS custom property declarations)
- The
data-themeattribute being set on a parent element (activates theme-specific variable values)
Solution
Ensure both the CSS import and thetheme prop are present:
[data-theme] selector:
Missing CSS Imports
Symptom
Components render as unstyled HTML elements — no backgrounds, no spacing, no borders. The layout is broken and elements stack vertically without proper structure.Root Cause
The UI Kit’s styles are distributed as a separate CSS entry point. Without importing it, none of the CSS custom properties or component styles are available in the document.Solution
Add the styles import at your application’s entry point, before any CometChat components render:@cometchat/chat-uikit-react/styles maps to the "./styles" export in the package’s exports map, which resolves to the compiled CSS file containing all component styles and theme variables.