Skip to main content
FieldValue
Package@cometchat/chat-uikit-react v7.0.x
Peer depsreact >=18, react-dom >=18, @cometchat/chat-sdk-javascript ^4.1.9, dompurify ^3.3.1
InitCometChatUIKit.init(UIKitSettings) — must resolve before login()
LoginCometChatUIKit.login("UID") — must resolve before rendering components
Orderinit()login() → render <CometChatProvider>. Breaking this order = blank screen
Auth KeyDev/testing only. Use Auth Token in production
CallingOptional. Install @cometchat/calls-sdk-javascript and call .setCallingEnabled(true) on UIKitSettingsBuilder
Other frameworksNext.js · React Router · Astro
This guide walks you through adding CometChat to a React.js app. By the end you’ll have a working chat UI.

Prerequisites

You need three things from the CometChat Dashboard:
CredentialWhere to find it
App IDDashboard → Your App → Credentials
Auth KeyDashboard → Your App → Credentials
RegionDashboard → Your App → Credentials (e.g. us, eu, in)
You also need Node.js 18+ and npm/yarn installed.
Auth Key is for development only. In production, generate Auth Tokens server-side via the REST API. Never ship Auth Keys in client code.

Step 1 — Create a React Project


Step 2 — Install the UI Kit

If you want voice/video calling, also install:

Step 3 — Initialize, Login, and Render

Call CometChatUIKit.init() and CometChatUIKit.login() before rendering your app. Then wrap your components in CometChatProvider. For development, use one of the pre-created test UIDs: cometchat-uid-1 · cometchat-uid-2 · cometchat-uid-3 · cometchat-uid-4 · cometchat-uid-5
src/main.tsx
src/App.tsx
CometChatProvider supplies theme, locale, plugin registry, and event context to all child components. Init and login must complete before the provider mounts. See the CometChatProvider guide for all props.
For production, use CometChatUIKit.loginWithAuthToken(token) instead of login(uid). Generate auth tokens server-side via the REST API. Never ship auth keys in client code.
By default, session data is stored in localStorage. To use sessionStorage instead, see Setting Session Storage Mode.

Step 4 — Run

Open http://localhost:5173 (Vite) or http://localhost:3000 (CRA). You should see the conversation list on the left. Click a conversation to open the message panel.

Choose a Chat Experience

Conversation List + Message View

Two-panel layout — conversation list on the left, messages on the right.

One-to-One / Group Chat

Single chat window — no sidebar. Good for support chat or embedded widgets.

Tab-Based Chat

Tabbed navigation — Chat, Call Logs, Users, Settings in separate tabs.

Build Your Own Chat Experience

Need full control over the UI? Use individual components, customize themes, and wire up your own layouts.
  • Sample App — Working reference app to compare against
  • Components — All prebuilt UI elements with props and customization options
  • Core Features — Messaging, real-time updates, and other capabilities
  • Theming — Colors, fonts, dark mode, and custom styling
  • Build Your Own UI — Skip the UI Kit entirely and build on the raw SDK

iFrame Embedding

If your React app runs inside an <iframe>, wrap your tree in CometChatFrameProvider so dialogs and portals mount in the correct frame:
PropTypeDescription
iframeIdstringThe DOM id of the target <iframe> element

Next Steps

Components Overview

Browse all prebuilt UI components

Theming

Customize colors, fonts, and styles

Plugins

Customize message rendering

Troubleshooting

Common issues and fixes