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):
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.
<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).
<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'].
<ChatMain {...chatConfig} queryParams={{ branchId: "12" }} queryParamApis={["conversations"]}/>queryParamApis values
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.
// Correct - specific keys inside queryParamsByApiqueryParamsByApi={{ conversations: { branchId: "12" }, createGroup: { orgId: "x" }, presignedUrls: { bucket: "chat-uploads" },}} // Correct - 'all' / 'get' used only with queryParamApisqueryParamApis={["all"]} // every request receives queryParamsqueryParamApis={["get"]} // default: every GET request receives queryParams // Incorrect - 'all' / 'get' are not queryParamsByApi keysqueryParamsByApi={{ all: { branchId: "12" } }} // ignoredImperative 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.
import { setChatQueryParams, setChatQueryParamApis, setChatQueryParamsByApi,} from "@realtimexsco/live-chat"; setChatQueryParams({ branchId: "12" });setChatQueryParamApis(["conversations"]);setChatQueryParamsByApi({ messages: { locale: "en" } });