RealTimeX
Start For Free

RealTimeX

Package Documentation

IntroductionPrerequisitesInstallationProject setupQuick start
Package structureConfigurationComponentsHooksAPI integrationSocket events
OverviewReplace entire UIReplace componentsStyle with classNamesThemes & localePhone & video callingIn-call control barFeatures
TroubleshootingFAQVersion historyBest practicesSupport & contact

Package 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
src/
|-- configs/
|   |-- chat.config.ts               # credentials only
|   |-- chat.customization.config.ts # components + classNames
|   |-- chat.layout.config.ts        # layout section toggles
|-- components/chat/custom/
|   |-- ElstarMembersDrawer.tsx      # custom drawer example
|   |-- ElstarChatAvatar.tsx
|   |-- index.ts
|-- 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
import ChatMain from "@realtimexsco/live-chat";
import { chatConfig } from "@/configs/chat.config";
import { chatCustomization } from "@/configs/chat.customization.config";
import { chatLayoutConfig } from "@/configs/chat.layout.config";

export default function ChatPage() {
  return (
    <ChatMain
      {...chatConfig}
      layout={chatLayoutConfig}
      components={chatCustomization.components}
      classNames={chatCustomization.classNames}
      features={chatCustomization.features}
      viewportHeight="calc(100dvh - 4rem)"
    />
  );
}

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
import {
  mergeChatLayoutConfig,
  defaultChatLayoutConfig,
} from "@realtimexsco/live-chat";

export const chatLayoutConfig = mergeChatLayoutConfig({
  ...defaultChatLayoutConfig,
  sidebar: true,
  input: true,
});
  • 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