RealTimeX
Sign inStart for free
RealTimeXWeb Package
IntroductionPrerequisitesInstallationProject setupQuick start
Package structureConfigurationComponentsHooksAPI integrationSocket events
OverviewReplace entire UIReplace componentsStyle with classNamesThemes & localePhone & video callingIn-call control barFeatures
Unread badgeRich-text messagesPins, stars & datesMessage threadsMentionsCanvas & draftsNotificationsAdmin permissionsServer refusalsSession & token refresh
Host app integrationTroubleshootingFAQVersion historyBest practicesSupport & contact
Web packagePackage reference

Configuration

Every ChatMain prop, the layout toggles, and the composable Chat provider.

ChatMain props reference

Only clientId, loggedUserDetails and apiUrl are required. Everything else has a sensible default.

Connection & session

PropTypeDefaultDescription
clientIdstring—Required. Tenant / client id
accessTokenstring—JWT access token. Omit it to let the package call the client-user login API and create the session itself
refreshTokenstring—Used to silently get a new accessToken when a request returns 403 “Invalid or expired token”
loggedUserDetailsobject—Required. { _id, name, email } - _id must match the JWT
apiUrlstring—Required. REST API ending with /api/v1
apiVersionsChatApiVersionConfig—API versions after /api, e.g. { v1: "v1", v2: "v2" } (v2 is needed for the unread badge)
socketUrlstringderivedSocket host (no /api/v1). Defaults to apiUrl without /api/v1
queryParamsRecord<string, string | number | boolean>—Extra query params - see API integration
queryParamApisChatApiKey[]['get']Which APIs receive queryParams. Default: all GET endpoints
queryParamsByApiChatQueryParamsByApi—Different query params per API key

Viewport & theme

PropTypeDefaultDescription
viewportHeight"full" | "screen" | string"full"Height of the built-in viewport - "screen", a CSS length like "calc(100dvh - 4rem)", or fill the parent
viewportClassNamestring—Extra classes on the built-in viewport wrapper
themeColorstring"#7494ec"Brand accent - hex, named CSS color, rgb/hsl, or var(--token)
fontFamilystringinheritedCSS font family for the whole chat
fontSizeChatFontSizeper roleOne size (scales every role) or { base, title, subtitle, description }. Numbers mean px
sectionBorderColorstringthemeBorder color of drawer / section list items (--chat-section-border)
sectionBorderRadiusstringthemeBorder radius of drawer / section list items, e.g. "8px"
themeTokensChatThemeTokens—Override any --chat-* design token per mode: { light: {…}, dark: {…} }
colorMode"light" | "dark"—Controlled color mode (your app owns the theme)
defaultColorMode"light" | "dark""light"Initial mode when uncontrolled
onColorModeChange(mode) => void—Called when the theme changes
showColorModeTogglebooleantrueShow the built-in light/dark toggle in account settings

Details and examples: Themes & locale.

Locale & time

PropTypeDefaultDescription
localestringbrowserBCP 47 locale, e.g. "en-US"
timeZonestringbrowserIANA time zone, e.g. "Asia/Kolkata"
hour12booleanlocaletrue = 12-hour clock
defaultLocalestring—Initial locale when uncontrolled
defaultTimeZonestring—Initial time zone when uncontrolled
defaultHour12boolean—Initial 12/24h when uncontrolled
onDateTimePreferencesChange(prefs) => void—The user changed date/time settings
showDateTimeSettingsbooleantrueShow the in-panel date/time button

UI & callbacks

PropTypeDefaultDescription
layoutChatLayoutConfigsee belowToggle UI sections
componentsChatComponents—Replace UI components (Case 1 & 2)
classNamesChatClassNames—Per-region CSS classes (Case 3)
featuresChatFeatures—Phone/video flags, callbacks and call controls
uiConfigUIConfig—Advanced: merged with components / classNames / features
error / infostring | null—Show an error / info banner in the chat panel
onErrorDismiss / onInfoDismiss() => void—Dismiss the banner
onUnreadCountChange(summary) => void—Workspace unread badge - assign, don't accumulate
onSessionEnd(event) => void—An admin ended this session - show your sign-in screen

See Unread badge and Session end & token refresh.

Layout sections (layout prop)

Toggle parts of the default UI without writing components:

typescript
1import { defaultChatLayoutConfig } from "@realtimexsco/live-chat";2 3export const chatLayoutConfig = {4  ...defaultChatLayoutConfig,5  // sidebar: true,           // left panel wrapper6  // loggedUserDetails: true, // profile + new chat button7  // channelList: true,       // conversation list8  // header: true,            // channel header bar9  // messageList: true,       // message bubbles10  // input: true,             // composer11  // forwardModal: true,      // forward dialog12  // threadsInbox: false,     // "Threads" inbox button in the sidebar (off by default)13  // mentions: false,         // "@" Mentions page button in the sidebar (off by default)14};
tsx
1layout={{ input: false }}         // read-only (no composer)2layout={{ sidebar: false }}        // hide the sidebar - messages only3layout={{ forwardModal: false }}   // disable the forward modal4layout={{ loggedUserDetails: false, channelList: true }}  // list without the profile block5layout={{ threadsInbox: true }}    // show the Threads inbox in the sidebar6layout={{ mentions: true }}        // show the Mentions page button in the sidebar

Chat provider (composable mode)

Use Chat + ChatLayout when you need your own page wrapper but not a full ChatMain replacement.

tsx
1"use client";2 3import { Chat, ChatLayout, type ChatComponents } from "@realtimexsco/live-chat";4import { chatConfig } from "@/configs/chat.config";5 6const components: ChatComponents = { Avatar: MyAvatar };7 8export default function ChatPage() {9  return (10    <div className="h-dvh min-h-0 overflow-hidden">11      <Chat12        client={{ id: chatConfig.clientId }}13        accessToken={chatConfig.accessToken}14        loggedUserDetails={chatConfig.loggedUserDetails}15        apiUrl={chatConfig.apiUrl}16        socketUrl={chatConfig.socketUrl}17        themeColor={chatConfig.themeColor}18        uiConfig={{19          components,20          classNames: { sidebar: "bg-slate-900" },21        }}22      >23        <ChatLayout themeColor={chatConfig.themeColor} />24      </Chat>25    </div>26  );27}

Note

In composable mode, pass fontFamily, fontSize and themeTokens to ChatThemeProvider - the same place themeColor goes.

Chat provider props

PropTypeRequiredDescription
client{ id: string }YesClient id
accessTokenstringNoJWT (omit to let the package log in itself)
refreshTokenstringNoRenews accessToken on 403 “expired token”
loggedUserDetailsobjectYesUser profile
apiUrlstringNoREST base URL
apiVersionsChatApiVersionConfigNoAPI versions after /api
socketUrlstringNoSocket host
queryParamsChatQueryParamsNoShared query params (default target: all GET APIs)
queryParamApisChatApiKey[]NoWhich APIs receive queryParams (default ['get'])
queryParamsByApiChatQueryParamsByApiNoPer-API query params
themeColorstringNoAccent color
uiConfigUIConfigNocomponents, classNames, features
onMessageReceived(msg) => voidNoBackground message callback
onSocketConnected(id) => voidNoSocket connected
onSocketError(err) => voidNoSocket error
onUnreadCountChange(summary) => voidNoWorkspace unread badge - assign, don't accumulate
onSessionEnd(event) => voidNoAdmin ended the session - show sign-in
childrenReactNodeYesUsually <ChatLayout />
PreviousPackage structureNextComponents

On this page

ChatMain props referenceConnection & sessionViewport & themeLocale & timeUI & callbacksLayout sections (layout prop)Chat provider (composable mode)Chat provider props
Back to top