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

Package Structure

Recommended project folder structure

For production integrations - especially inside admin templates such as Elstar or Metronic - RealtimeX recommends separating credentials, UI overrides, and layout toggles into their own config files. That keeps secrets out of layout code and makes customization reviewable in isolation.

text
1src/2|-- configs/3|   |-- chat.config.ts               # credentials only4|   |-- chat.customization.config.ts # components + classNames5|   |-- chat.layout.config.ts        # layout section toggles6|-- components/chat/custom/7|   |-- ElstarMembersDrawer.tsx      # custom drawer example8|   |-- ElstarChatAvatar.tsx9|   |-- index.ts10|-- views/Chat.tsx                   # wires up ChatMain

Wiring it together

Import the three config modules into your chat page and spread them onto ChatMain. Layout and customization stay optional - start with credentials alone, then layer overrides as your design requires.

tsx
1import ChatMain from "@realtimexsco/live-chat";2import { chatConfig } from "@/configs/chat.config";3import { chatCustomization } from "@/configs/chat.customization.config";4import { chatLayoutConfig } from "@/configs/chat.layout.config";5 6export default function ChatPage() {7  return (8    <ChatMain9      {...chatConfig}10      layout={chatLayoutConfig}11      components={chatCustomization.components}12      classNames={chatCustomization.classNames}13      features={chatCustomization.features}14      viewportHeight="calc(100dvh - 4rem)"15    />16  );17}

Components exported by the package

High-level exports you will import most often. The full slot map — including drawers, message parts, and call buttons - is documented in Components.

ExportRole
ChatMainDefault entry - credentials, providers, and UI in one component
Chat / ChatLayout / DefaultChatLayoutComposable shell pieces for advanced layouts
Channel / ChannelList / ChannelHeaderConversation sidebar and active-channel chrome
MessageList / MessageInput / MessageItemThread rendering and composer
ChatThemeProvider / ChatLocaleProvider / ChatAlertsProvider / ChatCustomizationProviderContext providers used internally; rarely needed directly
ChatAvatar / ChannelListItem / HeaderCallActions / packageDefaultComponentsBuilding blocks and the default component map for overrides

Hooks exported by the package

Prefer these hooks inside custom slots and layouts. Full signatures and examples are on the Hooks page.

  • useChatStore - Zustand store for messages, conversations, and socket actions
  • useChatController - state and handlers for building a custom ChatLayout
  • useChatContext - low-level chat provider context
  • useChatCustomization / useChatCustomizationOptional — current components and classNames
  • useChatFeatures / useChatFeaturesOptional — phone/video flags and callbacks
  • useChatTheme - themeColor, isDark, and CSS variables
  • useChatLocale - date/time formatting helpers using the active locale
  • useChatAlerts - error/info alert state

Utilities exported by the package

Helpers for layout/customization merges, imperative credential setup, and query-param configuration. See Configuration and API Integration for how they map to ChatMain props.

tsx
1import {2  mergeChatLayoutConfig,3  defaultChatLayoutConfig,4} from "@realtimexsco/live-chat";5 6export const chatLayoutConfig = mergeChatLayoutConfig({7  ...defaultChatLayoutConfig,8  sidebar: true,9  input: true,10});
  • mergeChatLayoutConfig, defaultChatLayoutConfig - layout section helpers
  • mergeChatCustomization, defaultChatClassNames, defaultChatComponents, defaultChatFeatures
  • setChatClientId, setChatAccessToken, setChatBaseURL, setChatSocketUrl - imperative API setup
  • setChatQueryParams / getChatQueryParams, setChatQueryParamApis / getChatQueryParamApis, setChatQueryParamsByApi / getChatQueryParamsByApi
  • CHAT_API_KEYS, CHAT_GET_API_KEYS, resolveChatApiKey
  • socketService, getSocketConfig
  • showNotification, downloadFile
PreviousQuick startNextConfiguration

On this page

Recommended project folder structureWiring it togetherComponents exported by the packageHooks exported by the packageUtilities exported by the package
Back to top