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
CometChatUIKit.loginWithAuthToken(token) instead of login(uid).
Props
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
plugins | CometChatMessagePlugin[] | No | — | Additional plugins beyond the defaults |
config | CometChatGlobalConfig | No | {} | Global flags (hideReceipts, hideUserStatus, etc.) |
theme | "light" | "dark" | No | "light" | Active theme |
locale | string | No | "en-us" | Language code for localization |
children | ReactNode | Yes | — | Your app content |
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 theplugins prop:
With Global Config
Accessing the Logged-In User
Inside your components (children ofCometChatProvider), 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 — callinit() then login(), then render. v7 works the same way:
v6 (before)
v7 (after)
- v7 uses
CometChatProviderto 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)