Package Reference
Best Practices
Overview
These recommendations come from the most common integration issues we see when teams embed @realtimexsco/live-chat into React and Next.js apps. Follow them early to avoid silent message bugs, broken styling, and duplicate React instances.
For a step-by-step install checklist, see Support & Contact. For symptom-based fixes, use Troubleshooting.
Credentials and config
- Keep secrets and connection values in
chat.config.ts(or environment variables), and keep UI overrides in a separate customization module. That matches the production layout described in Package Structure. - Always verify
loggedUserDetails._idagainst the JWT payload before shipping. A mismatched id is the most common cause of "messages appear on the wrong side" bugs. - Prefer environment variables for
clientId,apiUrl, andsocketUrlso the same config file works across local, staging, and production.
Customization
- Only pass the
componentsandclassNameskeys you intend to override. Every omitted key falls back to the package default — never pass empty placeholder components for slots you want to keep. - Use
packageDefaultComponentsto wrap and restyle a default component instead of rebuilding it from scratch. See Components and Customization. - Never import a package component inside your own replacement for that same slot (for example, importing
HeaderCallActionsinside a customHeaderCallActions). That creates infinite recursion. - Pin the package to
1.1.56or later if you customize drawers (MembersDrawer,ChannelDetailsDrawer, and related slots).
Layout and viewport
- Set an explicit height chain with
viewportHeightor a wrappingh-dvh min-h-0 overflow-hiddencontainer. Without it, the whole page scrolls instead of only the message list. - Prefer
viewportHeight="screen"for a full-page chat, orviewportHeight="calc(100dvh - 4rem)"under a fixed admin header. Details are in Quick Start.
Framework setup
- In Next.js, add
"use client"on any file that imports the chat package, and includetranspilePackagesinnext.config.ts. - In Vite, add
@realtimexsco/live-chattooptimizeDeps.excludeand dedupe React, Zustand, and Socket.IO to avoid duplicate-instance errors. - Complete Tailwind v4
@sourcepaths and--chat-theme*tokens as shown in Project Setup— missing CSS setup is the usual reason the UI looks unstyled.
API and realtime
- Use
queryParamsByApiwhen different GET endpoints need different filter keys, instead of forcing one sharedqueryParamsobject. See API Integration. - Remember that query-param props apply to REST only — they do not change the Socket.IO connection string. See Socket Events.