Getting Started
Start your first conversation
CometChat UI Kit for React Native is a collection of prebuilt UI components designed to simplify the development of an in-app chat with all the essential messaging features. Our UI Kit offers light and dark themes, various fonts, colors, and additional customization options.
CometChat UI Kit supports both one-to-one and group conversations. Follow the guide below to initiate conversations from scratch using CometChat React Native UI Kit.

Prerequisites
Before installing UI Kit for React Native, you need to create a CometChat application on the CometChat Dashboard, which comprises everything required in a chat service including users, groups, calls & messages. You will need the App ID
, AuthKey
, Region
of your CometChat application when initialising the SDK.
i. Register on CometChat
- To install UI Kit for React Native, you need to first register on CometChat Dashboard. Click here to sign up.
ii. Get Your Application Keys
- Create a new app
- Head over to the QuickStart or API & Auth Keys section and note the App ID, Auth Key, and Region.
Each CometChat application can be integrated with a single client app. Within the same application, users can communicate with each other across all platforms, whether they are on mobile devices or on the web.
Getting Started
You can quickly start building a modern messaging experience into your app by installing the new UI Kit, an add-on for the CometChat React Native SDK.
Step 1
Create a project
To get started, open terminal
and create a new project using below command.
- Bash
npx @react-native-community/cli init ChattingApp --version 0.77.0
CometChat React Native UI Kit is built and verified to work with React Native version 0.77. It might work with older versions, but newer versions are not supported and may cause unexpected issues.
Step 2
Add Dependency
You can install UI Kit for React Native through using below command.
- Bash
npm i @cometchat/chat-uikit-react-native
Other Dependencies
- Bash
npm i @cometchat/chat-sdk-react-native
npm i @react-native-community/datetimepicker
npm i @react-native-clipboard/clipboard
npm i react-native-svg
npm i react-native-video
npm i dayjs
npm i @react-native-async-storage/async-storage
Add Permissions for android
Open AndroidManifest.xml
file from android/app/src/main
location and add below permissions
- XML
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
Please make sure Android SDK path is set in the ANDROID_HOME
environment variable or in local.properties
via the field sdk.dir
.
Install @cometchat/calls-sdk-react-native Package (Optional)
To enable calling functionality in your application, you need to install the Calling SDK separately within your project.
React Native UI Kit supports Calls SDK V3 or higher.
-
You can install
@cometchat/calls-sdk-react-native
Calling SDK for React Native using below command.- Bash
npm i @cometchat/calls-sdk-react-native
-
Install dependancies required for call SDK to work
- JSON
// Dependencies required for calls sdk.
{
"@cometchat/chat-sdk-react-native": "^4.0.5",
"@react-native-async-storage/async-storage": "^1.17.5",
"@react-native-community/netinfo": "7.1.7", // for react-native 0.63 & above.
"@react-native-community/netinfo": "6.1.0", // for react-native below 0.63
"react-native-background-timer": "2.4.1",
"react-native-callstats": "3.73.7",
"react-native-webrtc": "1.106.1"
} -
Add permissions
Android:
- XML
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />IOS:
- XML
<key>NSCameraUsageDescription</key>
<string>This is for Camera permission</string>
<key>NSMicrophoneUsageDescription</key>
<string>This is for Mic permission</string>
Step 3
Initialise CometChatUIKit
To integrate and run CometChat UI Kit in your app, you need to initialize it beforehand.
The Init method initializes the settings required for CometChat. Please ensure to call this method before invoking any other methods from CometChat UI Kit or CometChat SDK.
The Auth Key is an optional property of the UIKitSettings
Class. It is intended for use primarily during proof-of-concept (POC) development or in the early stages of application development. You can use the Auth Token method to log in securely.
- Typescript
import React, {useEffect} from 'react'
import { Platform, PermissionsAndroid } from 'react-native'
import { CometChatUIKit, UIKitSettings } from '@cometchat/chat-uikit-react-native'
import { CometChat } from '@cometchat/chat-sdk-react-native'
// add below code in App.js or App.tsx
const getPermissions = () => {
if (Platform.OS == "android") {
PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
PermissionsAndroid.PERMISSIONS.CAMERA,
PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
]);
}
}
useEffect(() => {
getPermissions();
let uikitSettings: UIKitSettings = {
appId: "Enter your App ID here", // Replace with your CometChat App ID
authKey: "Enter your Auth Key here", // Replace with your App Auth Key
region: "Enter your App Region here", // e.g., "us", "in"
subscriptionType: CometChat.AppSettings
.SUBSCRIPTION_TYPE_ALL_USERS as UIKitSettings['subscriptionType'],
};
CometChatUIKit.init(uikitSettings)
.then(() => {
console.log("CometChatUiKit successfully initialized")
})
.catch((error) => {
console.log("Initialization failed with exception:", error)
})
},[]);
Login User
For login, you require a UID. You can create your own users on the CometChat Dashboard or via API. We have pre-generated test users: cometchat-uid-1, cometchat-uid-2, cometchat-uid-3, cometchat-uid-4, cometchat-uid-5.
The Login method returns the User object containing all the information of the logged-in user.
This straightforward authentication method is ideal for proof-of-concept (POC) development or during the early stages of application development. For production environments, however, we strongly recommend using an Auth Token instead of an Auth Key to ensure enhanced security.
- Typescript
// Replace with the actual user ID you want to log in
const uid = '<YOUR_USER_UID>';
// Login user with CometChatUIKit
CometChatUIKit.login({uid})
.then(user => {
// Login successful
console.log(`User logged in successfully: ${user.getName()}`);
})
.catch(error => {
// Handle login error
console.error('Login failed with error:', error);
});
Step 5
Render Conversations with Messages
Loading the Conversations Component

- App.tsx
import React, {useEffect, useState} from 'react';
import {
Platform,
PermissionsAndroid,
SafeAreaView,
ViewStyle,
} from 'react-native';
import {
CometChatConversations,
CometChatUIKit,
CometChatUiKitConstants,
UIKitSettings,
CometChatThemeProvider,
} from '@cometchat/chat-uikit-react-native';
import {CometChat} from '@cometchat/chat-sdk-react-native';
import Messages from './src/components/Messages';
/* -------------------------------------------------------------------------- */
/* ⚙️ Replace the placeholders below with your own CometChat credentials. */
/* -------------------------------------------------------------------------- */
const APP_ID = '<APP_ID>'; // e.g. "123456abc"
const AUTH_KEY = '<AUTH_KEY>'; // e.g. "0b1c2d3e4f5g6h7i8j9k"
const REGION = '<REGION>'; // e.g. "us" | "eu" | "in"
const DEMO_UID = '<UID>'; // e.g. "john_doe"
/* -------------------------------------------------------------------------- */
/**
* App
* ---
* The root component:
* 1. Initializes the CometChat UI Kit.
* 2. Logs a demo user in.
* 3. Shows either the conversation list or an active chat screen.
*/
const App = (): React.ReactElement => {
/* ------------------------------------------------------------------ */
/* Local state */
/* ------------------------------------------------------------------ */
const [loggedIn, setLoggedIn] = useState(false);
const [messageUser, setMessageUser] = useState<CometChat.User>();
const [messageGroup, setMessageGroup] = useState<CometChat.Group>();
/* ------------------------------------------------------------------ */
/* One-time initialization */
/* ------------------------------------------------------------------ */
useEffect(() => {
const init = async () => {
// 1️⃣ Configure the UI Kit.
const uiKitSettings: UIKitSettings = {
appId: APP_ID,
authKey: AUTH_KEY,
region: REGION,
subscriptionType: CometChat.AppSettings
.SUBSCRIPTION_TYPE_ALL_USERS as UIKitSettings['subscriptionType'],
};
try {
await CometChatUIKit.init(uiKitSettings);
console.log('[CometChatUIKit] initialized');
// 2️⃣ Android runtime permissions (camera, mic, etc.).
await requestPermissions();
// 3️⃣ Login.
await CometChatUIKit.login({uid: DEMO_UID});
setLoggedIn(true);
} catch (err) {
console.error('[CometChatUIKit] init/login error', err);
}
};
init();
}, []);
/* ------------------------------------------------------------------ */
/* Helper: request common Android permissions */
/* ------------------------------------------------------------------ */
const requestPermissions = async (): Promise<void> => {
if (Platform.OS !== 'android') return;
try {
const granted = await PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
PermissionsAndroid.PERMISSIONS.CAMERA,
PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS,
]);
const allGranted = Object.values(granted).every(
status => status === PermissionsAndroid.RESULTS.GRANTED,
);
if (!allGranted) {
console.warn('[Permissions] Not all permissions granted');
}
} catch (err) {
console.warn('[Permissions] Error requesting Android permissions', err);
}
};
/* ------------------------------------------------------------------ */
/* Render */
/* ------------------------------------------------------------------ */
return (
<SafeAreaView style={styles.fullScreen}>
<CometChatThemeProvider>
{/* Show conversations only after the user is logged in */}
{loggedIn && (
<>
{/* Conversation list (hidden when a chat is open) */}
<CometChatConversations
style={{
containerStyle: {
display: messageUser || messageGroup ? 'none' : 'flex',
},
}}
onItemPress={(conversation: CometChat.Conversation) => {
if (
conversation.getConversationType() ===
CometChatUiKitConstants.ConversationTypeConstants.user
) {
setMessageUser(
conversation.getConversationWith() as CometChat.User,
);
return;
}
setMessageGroup(
conversation.getConversationWith() as CometChat.Group,
);
}}
/>
{/* Active chat screen */}
{(messageUser || messageGroup) && (
<Messages
user={messageUser}
group={messageGroup}
onBack={() => {
setMessageUser(undefined);
setMessageGroup(undefined);
}}
/>
)}
</>
)}
</CometChatThemeProvider>
</SafeAreaView>
);
};
/* -------------------------------------------------------------------------- */
/* Styles */
/* -------------------------------------------------------------------------- */
const styles: {fullScreen: ViewStyle} = {
fullScreen: {flex: 1},
};
export default App;
Loading the Messages Component

- The Messages component allows users to view and send messages in both one-on-one and group conversations.
- Messages.tsx
import React from 'react';
import { View, StyleSheet } from 'react-native';
import {
CometChatMessageHeader,
CometChatMessageList,
CometChatMessageComposer,
} from '@cometchat/chat-uikit-react-native';
import { CometChat } from '@cometchat/chat-sdk-react-native';
/**
* Messages
* --------
* A self-contained chat screen that combines the **CometChatMessageHeader**, **CometChatMessageList**,
* and **CometChatMessageComposer** provided by the CometChat React-Native UI Kit.
*
* Props
* -----
* • `user` – (CometChat.User, optional) Target user for a 1-to-1 conversation.
* • `group` – (CometChat.Group, optional) Target group for a group conversation.
* • `onBack`— () ⇒ void Callback fired when the back button in the header is pressed.
*
*/
const Messages = ({
user,
group,
onBack,
}: {
user?: CometChat.User;
group?: CometChat.Group;
onBack: () => void;
}) => {
return (
<View /* root container fills the entire screen */ style={styles.root}>
{/* Top bar: avatar, name & back button */}
<CometChatMessageHeader
user={user}
group={group}
onBack={onBack}
showBackButton
/>
{/* Scrollable list of chat messages */}
<CometChatMessageList user={user} group={group} />
{/* Input field + action buttons (emoji, attach, send, etc.) */}
<CometChatMessageComposer user={user} group={group} />
</View>
);
};
const styles = StyleSheet.create({
/** Ensures the component stretches to use all available space */
root: {
flex: 1,
},
});
export default Messages;