Skip to main content

Overview

Every CometChat component must be rendered inside a <CometChatProvider> which supplies theme, locale, plugin registry, global config, and real-time events to the component tree. CometChatProvider does not handle SDK initialization or user login. You must call CometChatUIKit.init() and CometChatUIKit.login() (or loginWithAuthToken()) imperatively before mounting the provider.

Setup Pattern

The setup is always the same: initialize, login, then render.
src/main.tsx
src/App.tsx
For production, use CometChatUIKit.loginWithAuthToken(token) instead of login(uid).

Props


With Custom Theme and Locale


With Additional Plugins

All default plugins (text, image, file, audio, video, AI, etc.) are always included. Pass your own custom plugins via the plugins prop:

Removing Plugins

Use removePlugins to exclude plugins — including defaults — so their message types no longer render. Each entry matches a plugin by its message type (text) and category (category); a plugin is removed when its messageTypes includes the text value and its messageCategories includes the category value.
Pass multiple entries to remove several plugins at once:
The text field is the message type (e.g. extension_poll, text, image), not literal text. Look up a plugin’s type and category in the Plugins table.

With Global Config


Accessing the Logged-In User

Inside your components (children of CometChatProvider), access the logged-in user via the useLoggedInUser() hook or CometChatUIKit.getLoggedInUser():

Internal Architecture

CometChatProvider composes these internal providers in order:

Next.js App Router

CometChatProvider uses browser APIs internally, so it must be placed inside a Client Component. Additionally, init and login must happen client-side.
app/providers.tsx

Migration from v6

In v6, initialization was imperative — call init() then login(), then render. v7 works the same way:
v6 (before)
v7 (after)
Key differences:
  • v7 uses CometChatProvider to supply React context (theme, locale, plugins, events)
  • Init and login are still imperative — same as v6
  • Default plugins are included automatically
  • Theme and locale are props on the provider
  • Real-time events are managed internally (no RxJS, no manual listener setup)