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

API Integration

The package ships its own Axios-based REST client, pointed at the apiUrl you provide. You can pass additional query-string parameters into any of its GET (and optionally POST/PATCH) requests without forking the package.

Required backend endpoints

The client-side chat UI expects your backend to expose REST endpoints for the following operations (paths shown are the package's internal defaults):

KeyEndpointPurpose
loginPOST /user/login/client-userClient-user authentication (JWT exchange)
usersGET /user/listList selectable users for new chats
conversationsGET /conversation/listList the logged-in user's conversations
conversationInfoGET /conversation/get/information/:idConversation/channel details
messagesGET /message/get-all-from-conversationPaginated message history
pinnedMessagesGET /message/pinned-messagesPinned messages for a conversation
starredMessagesGET /message/starred-messagesStarred messages for the user
searchMessagesGET /message/search-messagesIn-chat message search
searchMessagesContextGET /message/searched-message/contextContext around a search hit
createGroupPOST /conversation/create-groupCreate a new group conversation
updateGroupPermissionsPATCH /conversation/update-group-permissionsUpdate who can post, edit, or manage the group
updateGroupInfoPATCH /conversation/update-group-infoUpdate group name, avatar, or description
manageMembersPATCH /conversation/manage-membersAdd or remove group members
manageAdminsPATCH /conversation/manage-adminsPromote or demote group admins
blockUnblockPOST /user/block-unblockBlock or unblock another user
presignedUrlsGET /attachment/presigned-urlRequest an S3 presigned URL for attachment upload

Note

These 16 keys are the complete, exact set of identifiers accepted inside queryParamsByApi. "all" and "get" are not entries of queryParamsByApi — they are values you pass to the separate queryParamApis prop to broadly target every request or every GET request. See the two tables below for the full distinction.

Passing extra query parameters

By default, queryParams apply only to GET requests (queryParamApis defaults to ['get']). Login and other write operations are unaffected unless you opt in with queryParamApis={['all']}.

Pattern 1 — same params on every GET request

Use when every GET call should receive the same extra keys (for example a branch or tenant id). Write operations stay untouched unless you change queryParamApis.

RequestResulting query string
GET /user/list?branchId=12
GET /conversation/list?limit=20&page=1&branchId=12
GET /message/get-all-from-conversation?conversationId=...&limit=...&branchId=12
POST /user/login/client-user(no extra query params)
tsx
<ChatMain
  {...chatConfig}
  queryParams={{ branchId: "12" }}
  // queryParamApis default = ['get']
/>

Pattern 2 — different params per GET endpoint

Prefer queryParamsByApi when each endpoint needs its own filters. Keys must match the API key table above (for example conversations, messages, presignedUrls).

tsx
<ChatMain
  {...chatConfig}
  queryParamsByApi={{
    conversations: { branchId: "12" },
    messages: { locale: "en" },
    users: { orgId: "x" },
  }}
/>

Pattern 3 — params on a single endpoint only

Narrow shared queryParams to one API by setting queryParamApis to that key instead of the default ['get'].

tsx
<ChatMain
  {...chatConfig}
  queryParams={{ branchId: "12" }}
  queryParamApis={["conversations"]}
/>

Combining shared and per-API params

Result: conversations receives ?tenant=abc&branchId=12; messages receives ?tenant=abc&locale=en.

tsx
<ChatMain
  {...chatConfig}
  queryParams={{ tenant: "abc" }}
  queryParamApis={["conversations", "messages"]}
  queryParamsByApi={{
    conversations: { branchId: "12" },
    messages: { locale: "en" },
  }}
/>

queryParamApis values

ValueMeaning
['get']Default. All GET endpoints in the table above
['all']Every apiClient request — GET, POST, and PATCH
Specific keys, e.g. ['conversations']Only the listed endpoints

All valid queryParamsByApi keys

queryParamsByApi accepts an object keyed by API identifier. The 16 keys below are the complete list of identifiers it recognizes — every REST call the package makes is addressable by one of these keys.

#Key
1login
2users
3conversations
4conversationInfo
5messages
6pinnedMessages
7starredMessages
8searchMessages
9searchMessagesContext
10createGroup
11updateGroupPermissions
12updateGroupInfo
13manageMembers
14manageAdmins
15blockUnblock
16presignedUrls
tsx
// Correct — specific keys inside queryParamsByApi
queryParamsByApi={{
  conversations: { branchId: "12" },
  createGroup: { orgId: "x" },
  presignedUrls: { bucket: "chat-uploads" },
}}

// Correct — 'all' / 'get' used only with queryParamApis
queryParamApis={["all"]}   // every request receives queryParams
queryParamApis={["get"]}   // default: every GET request receives queryParams

// Incorrect — 'all' / 'get' are not queryParamsByApi keys
queryParamsByApi={{ all: { branchId: "12" } }}   // ignored

Warning

"all" and "get" are not valid keys inside queryParamsByApi and will be ignored if used there. They are values for the separate queryParamApis prop only — queryParamApis={['all']} applies queryParams to every request, and queryParamApis={['get']} (the default) applies it to every GET request. To target a specific endpoint inside queryParamsByApi, use one of the 16 keys above.

Imperative helpers

Prefer the ChatMain props when the values are known at render time. Use these setters when credentials or filters arrive asynchronously after mount (for example after a host-app login completes) and you need to update the shared API client without remounting the whole tree.

tsx
import {
  setChatQueryParams,
  setChatQueryParamApis,
  setChatQueryParamsByApi,
} from "@realtimexsco/live-chat";

setChatQueryParams({ branchId: "12" });
setChatQueryParamApis(["conversations"]);
setChatQueryParamsByApi({ messages: { locale: "en" } });

Note

The socket connection's own query string is not affected by queryParams / queryParamsByApi. S3 presigned upload requests can be customized specifically through the presignedUrls key.
PreviousHooksNextSocket events

On this page

Required backend endpointsPassing extra query parametersPattern 1 — same params on every GET requestPattern 2 — different params per GET endpointPattern 3 — params on a single endpoint onlyCombining shared and per-API paramsqueryParamApis valuesAll valid queryParamsByApi keysImperative helpers