CometChatUIKit is a static class that provides imperative methods for SDK initialization, authentication, and message sending. The UI Kit wraps the Chat SDK methods to manage internal eventing and keep UI components synchronized. Use these wrapper methods instead of raw SDK calls.You must call CometChatUIKit.init() and CometChatUIKit.login() (or loginWithAuthToken()) before mounting CometChatProvider. These methods are also useful for:
Sending messages programmatically outside the composer
import { CometChatUIKit, UIKitSettingsBuilder } from "@cometchat/chat-uikit-react";const settings = new UIKitSettingsBuilder() .setAppId("APP_ID") .setRegion("us") .setAuthKey("AUTH_KEY") .subscribePresenceForAllUsers() .build();const user = await CometChatUIKit.init(settings);// user is non-null if an existing session was found
Parameter
Type
Description
settings
UIKitSettings
Built via UIKitSettingsBuilder
Returns:Promise<CometChat.User | null> — the logged-in user if a session exists, otherwise null.What it does:
Initializes the CometChat SDK with app settings
Sets source metadata for analytics
Creates the plugin registry (default + user plugins)
Both methods require authKey in your UIKitSettings — they throw if it is missing. Intended for development/testing; in production, create and update users server-side via the REST API.
import { CometChat } from "@cometchat/chat-sdk-javascript";const user = new CometChat.User("new-uid");user.setName("Alice");const created = await CometChatUIKit.createUser(user);