Skip to main content

Core Components

Ermis Chat React provides a set of highly customizable Core Components. The props below are directly mapped from the SDK's types.ts file to give you exhaustive control over overrides and behavior.


<ChatProvider />

The top-level provider for the chat application. It manages the global state context and passes it down.

Core Props

PropTypeDescription
clientErmisChatThe initialized SDK client instance.
childrenReact.ReactNodeChild components requiring context.
initialTheme'dark' | 'light'Initial layout theme (default: 'dark').

Example

import React, { useEffect, useState } from 'react';
import { ChatProvider } from '@ermis-network/ermis-chat-react';
import { ErmisChat } from '@ermis-network/ermis-chat-sdk';

export const AppBuilder = ({ userToken }) => {
const [chatClient, setChatClient] = useState<ErmisChat | null>(null);

useEffect(() => {
const initClient = async () => {
const client = new ErmisChat('API_KEY');
await client.connectUser({ id: 'user-1' }, userToken);
setChatClient(client);
};
initClient();
}, [userToken]);

if (!chatClient) return <p>Starting Ermis...</p>;

return (
<ChatProvider client={chatClient} initialTheme="light">
<YourAppLayout />
</ChatProvider>
);
};

Call Configuration

To enable 1-on-1 audio and video calls, set enableCall to true and provide a callSessionId.

caution

Before enabling calls, you must run npx ermis-init-call to copy the required WebAssembly and audio files into your public/ directory. See Audio & Video Calls for details.

PropTypeDefaultDescription
enableCallbooleanfalseEnables the call feature.
callSessionIdstringUnique session ID for the call node (required when enableCall is true).
callWasmPathstring'/ermis_call_node_wasm_bg.wasm'Path to the WASM module.
callRelayUrlstring'https://iroh-relay.ermis.network:8443'Relay server URL.
CallUIComponentReact.ComponentTypeErmisCallUIReplace the entire default call UI.
incomingCallAudioPathstring'/call_incoming.mp3'Audio file for incoming call ringtone.
outgoingCallAudioPathstring'/call_outgoing.mp3'Audio file for outgoing call ringtone.
onCallStart(type, cid) => voidCalled when a call is initiated.
onCallEnd(duration) => voidCalled when a call ends.
onCallError(error) => voidCalled when a call error occurs.
onIncomingCall(callerInfo) => voidCalled on incoming call.
onCallAccepted() => voidCalled when call is accepted.
onCallRejected() => voidCalled when call is rejected.
<ChatProvider
client={chatClient}
enableCall={true}
callSessionId="my-session-id"
onCallEnd={(duration) => console.log(`Call lasted ${duration}s`)}
>
<YourAppLayout />
</ChatProvider>
tip

For the full Call API reference including ErmisCallUI props, useCallContext hook, component slots, and CSS theming, see the dedicated Audio & Video Calls page.


<ChannelList />

Renders a list of available channels to select. Connects to socket events for realtime unread tracking.

Core Configs

PropTypeDescription
filtersChannelFiltersQuery filters to fetch specific channels.
sortChannelSortArray defining sort priority.
optionsChannelQueryOptionsAdditional query options.
classNamestringCustom CSS wrapper class name.
showOnlineStatusbooleanShow online/offline indicator dots on channel item avatars for friend channels.
onChannelSelect(channel: Channel) => voidEvent when user clicks a row.

Component Overrides

PropTypeDescription
renderChannel(channel: Channel, isActive: boolean) => React.ReactNodeCustom render mapped function.
ChannelItemComponentReact.ComponentType<ChannelItemProps>Overrides the wrapper for a single row.
AvatarComponentReact.ComponentType<AvatarProps>Overrides the default avatar element.
LoadingIndicatorReact.ComponentType<{ text?: string }>Custom loading spinner element.
EmptyStateIndicatorReact.ComponentType<{ text?: string }>Shown when network returns zero channels.

Localization (I18n)

PropTypeDescription
pendingInvitesLabelstring | ((count: number) => string)Header for pending invites list.
channelsLabelstringHeader for approved channel list.
pendingBadgeLabelstringHover text for pending badge limit.
blockedBadgeLabelstringHover text for blocked channel indicator.
loadingLabelstringText string during network sync.
emptyStateLabelstringText string for empty channel results.

Example

import { ChannelList } from '@ermis-network/ermis-chat-react';

export const MessagesSidebar = () => (
<ChannelList
filters={{ type: 'messaging' }}
sort={[{ last_message_at: -1 }]}
emptyStateLabel="Try starting a conversation."
onChannelSelect={(c) => console.log('Viewing:', c.id)}
/>
);

<Channel />

Establishes the active isolated context. Any message lists or info panels placed inside Channel hook into this specific data stream.

Props

PropTypeDescription
childrenReact.ReactNodeList or Composer components rendering data.
classNamestringStyles for outer layout wrapper.
EmptyStateIndicatorReact.ComponentTypeUI activated when ChatContext.activeChannel is null.
HeaderComponentReact.ComponentType<ChannelHeaderData>Replaces default top action bar natively.
ForwardMessageModalComponentReact.ComponentType<ForwardMessageModalProps>Used to replace the standard forwarding view.

Example

import { Channel } from '@ermis-network/ermis-chat-react';

const BlockedLayout = () => <div className="p-10">Select a channel first.</div>;

export const ChatArea = () => (
<Channel
className="h-full border-l border-gray-200"
EmptyStateIndicator={BlockedLayout}
>
<div className="flex flex-col h-full overflow-hidden">
{/* Insert message views here */}
</div>
</Channel>
);

<VirtualMessageList />

Advanced engine for rendering real-time message feeds via infinite cursor virtualization.

Core Configs

PropTypeDescription
classNamestringCustom CSS wrapper class name.
loadMoreLimitnumberMessages retrieved per batch (default: 25).
showPinnedMessagesbooleanDisplay float banner for pinned text.
showReadReceiptsbooleanEnables rendering receipts under sent logs.
readReceiptsMaxAvatarsnumberTruncation limit before displaying a number.
showTypingIndicatorbooleanAllows rendering animated typing nodes.

Component Overrides

PropTypeDescription
renderMessageFunctionDefault list elements bypass.
AvatarComponentReact.ComponentType<AvatarProps>Override chat profile display component.
MessageBubbleReact.ComponentType<MessageBubbleProps>Padding wrapper around text bodies.
messageRenderersPartial<Record<MessageLabel, React.ComponentType<MessageRendererProps>>>Map distinct render components to types.
DateSeparatorComponentReact.ComponentType<DateSeparatorProps>Divider block between target dates.
MessageItemComponentReact.ComponentType<MessageItemProps>Whole element layout replacement.
SystemMessageItemComponentReact.ComponentType<SystemMessageItemProps>Structural override for SDK driven system actions.
JumpToLatestButtonReact.ComponentType<JumpToLatestProps>Trigger floating scroll return element.
QuotedMessagePreviewComponentReact.ComponentType<QuotedMessagePreviewProps>Inline reply reference node module.
MessageActionsBoxComponentReact.ComponentType<MessageActionsBoxProps>Element tracking interactions.
PinnedMessagesComponentReact.ComponentType<any>Replaces sticky header entirely.
ReplyPreviewComponentReact.ComponentType<ReplyPreviewProps>Element displayed over composer.
ReadReceiptsComponentReact.ComponentType<ReadReceiptsProps>Block spanning active view status checks.
ReadReceiptsTooltipComponentReact.ComponentType<ReadReceiptsTooltipProps>Visual float tracking read timelines.
TypingIndicatorComponentReact.ComponentTypeLoader elements reflecting incoming keystrokes.
MessageReactionsComponentReact.ComponentType<MessageReactionsProps>Interactive emoji tag list wrapper.
EmptyStateIndicatorReact.ComponentTypeGraphic displayed prior to starting discussion.
MediaLightboxComponentReact.ComponentType<MediaLightboxProps>Replaces the default MediaLightbox entirely.
PendingInviteeNotificationComponentReact.ComponentType<{ inviteeName?: string, label?: string }>Notification banner for the inviter in a direct channel when the invitee is pending.

Localization (I18n)

PropTypeDescription
emptyTitlestringLabel for header.
emptySubtitlestringLabel for helper text.
jumpToLatestLabelstringLabel triggering downward scroll.
bannedOverlayTitlestringLabel for sanction headline.
bannedOverlaySubtitlestringLabel for sanction explanation.
blockedOverlayTitlestringLabel for blocked element.
blockedOverlaySubtitlestringLabel for blocked details.
pendingOverlayTitlestringLabel for invite screen.
pendingOverlaySubtitlestringLabel for invite helper.
pendingAcceptLabelstringLabel for affirmative selection.
pendingRejectLabelstringLabel for negative selection.
pendingSkipLabelstringLabel for skip button on direct messaging channels.
skippedOverlayTitlestringHeader for skipped channel overlay.
skippedOverlaySubtitlestringHelper text for skipped channel overlay.
skippedAcceptLabelstringRe-accept label on skipped overlay.
pendingInviteeLabelstring | ((inviteeName?: string) => string)Text shown to the inviter while waiting for the invitee.

Example

import { VirtualMessageList, useChatContext } from '@ermis-network/ermis-chat-react';

const SpecialMessageBubble = ({ message, isOwnMessage, children }) => (
<div className={`p-4 mt-2 max-w-[80%] rounded-[20px] ${isOwnMessage ? 'bg-green-500 text-white rounded-tr-none self-end' : 'bg-gray-100 rounded-tl-none self-start'}`}>
{children}
<p className="text-[10px] opacity-70 mt-1">{new Date(message.created_at).toLocaleTimeString()}</p>
</div>
);

export const LiveFeed = () => (
<VirtualMessageList
loadMoreLimit={50}
showReadReceipts={true}
emptyTitle="Crickets... 🦗"
MessageBubble={SpecialMessageBubble}
/>
);

<MessageInput />

The central textbox element orchestration supporting file drops, mentions, and editing logic.

Core Configs

PropTypeDescription
placeholderstringTextbox default string hint.
classNamestringStyles for module wrapper block.
disableAttachmentsbooleanDeactivates UI and logic for adding objects.
disableMentionsbooleanStops detection algorithms monitoring tags.
onSend(text: string) => voidEvent triggered after sending.
onBeforeSend(text: string, attachments: FilePreviewItem[]) => boolean | Promise<boolean>Functional interceptor allowing cancellation validation routines safely.
renderAbove() => React.ReactNodeExtends layout vertically over input.

UI Components

PropTypeDescription
SendButtonReact.ComponentType<SendButtonProps>Replace standard send symbol.
AttachButtonReact.ComponentType<AttachButtonProps>Replace standard clip symbol.
FilesPreviewComponentReact.ComponentType<FilesPreviewProps>Render queued elements prior to request submission.
MentionSuggestionsComponentReact.ComponentType<MentionSuggestionsProps>Replace default floating array container.
EmojiPickerComponentReact.ComponentType<EmojiPickerProps>Extensible block linking custom vendor keyboards.
EmojiButtonComponentReact.ComponentType<EmojiButtonProps>Triggers expanding smileys widget externally.
ReplyPreviewComponentReact.ComponentType<ReplyPreviewProps>Inline container displaying tracked message references.
EditPreviewComponentReact.ComponentType<{ message: FormatMessageResponse, onDismiss: () => void, editingMessageLabel?: string }>Interface appearing during inline structural modification tasks.

Localization (I18n) & Errors

PropTypeDescription
bannedLabelstringLabel alerting active lockouts.
blockedLabelstringLabel confirming severed connection.
linksDisabledLabelstringNotification when regex disables URL strings.
keywordBlockedLabel(match: string) => stringReturn parameter evaluating forbidden values.
sendDisabledLabelstringString output reflecting disabled status.
slowModeLabel(cooldown: number) => React.ReactNodeString indicating active throttling measures globally.

Example

import { MessageInput } from '@ermis-network/ermis-chat-react';

export const SmartComposer = () => (
<MessageInput
placeholder="Write your message here..."
onBeforeSend={async (text, attachments) => {
if (text.toLowerCase().includes("spam")) {
alert("This message looks like spam, you cannot send it.");
return false;
}
return true; // OK to proceed
}}
/>
);

<ChannelInfo />

The orchestration component for Right-sidebar drawer configurations. Driving internal forms handling profile updates, grids, and roles.

Core Configs & Listeners

PropTypeDescription
channelChannelOverwrites inherited object node globally.
classNamestringStyle injections for module framework.
titlestringStatic string overriding main navigation text.
onClose() => voidEvent mapping standard overlay disposal clicks.
onSearchClick() => voidEvent redirecting control toward custom panel.
onLeaveChannel() => voidFires executing logic.
onDeleteChannel() => voidFunctional removal executed.
onAddMemberClick() => voidMethod bypassing built-in array expansion nodes.
onRemoveMember(id: string) => voidValidation trigger intercepting deletions.
onBanMember(id: string) => voidIntercepts administration control elements.
onUnbanMember(id: string) => voidRescinds tracking flags programmatically.
onPromoteMember(id: string) => voidEvaluates moderator flag additions.
onDemoteMember(id: string) => voidLowers metric parameters correctly.
onBlockUser() => voidRejects connection.
onUnblockUser() => voidResolves connection.
onEditChannel(data: EditChannelData) => Promise<void>Callback processing input text before patching server nodes.

Component Overrides

PropTypeDescription
AvatarComponentReact.ComponentType<AvatarProps>Override graphic map.
HeaderComponentReact.ComponentType<ChannelInfoHeaderProps>Bypass navigation elements directly.
CoverComponentReact.ComponentType<ChannelInfoCoverProps>Renders large graphic profile banners.
ActionsComponentReact.ComponentType<ChannelInfoActionsProps>Replaces default functional trigger elements natively.
TabsComponentReact.ComponentType<ChannelInfoTabsProps>Updates layout displaying media toggle logic intuitively.
AddMemberModalComponentReact.ComponentType<AddMemberModalProps>Injects external popup architecture visually completely.
EditChannelModalComponentReact.ComponentType<EditChannelModalProps>Allows specific control over update displays externally.
MemberItemComponentReact.ComponentType<ChannelInfoMemberItemProps>Evaluates user rendering inside mapping objects dynamically.
MediaItemComponentReact.ComponentType<ChannelInfoMediaItemProps>Structure formatting grid photos individually.
LinkItemComponentReact.ComponentType<ChannelInfoLinkItemProps>Display layout extracting URLs intelligently.
FileItemComponentReact.ComponentType<ChannelInfoFileItemProps>Maps download elements flawlessly.
EmptyStateComponentReact.ComponentType<ChannelInfoEmptyStateProps>Fills grids holding empty definitions organically.
LoadingComponentReact.ComponentTypeOverload standard graphic spinning loops manually.
AddMemberButtonComponentReact.ComponentType<AddMemberButtonProps>Standard explicit interaction icon completely.

Add Member Localization

PropTypeDescription
addMemberModalTitlestringHeader string.
addMemberSearchPlaceholderstringBlank explicit text.
addMemberLoadingTextstringStatus tag element.
addMemberEmptyTextstringZero match prompt.
addMemberAddLabelstringStandard action button.
addMemberAddingLabelstringDynamic toggle state.
addMemberAddedLabelstringStatic check graphic.
addMemberButtonLabelstringList head parameter.

Edit Channel Localization

PropTypeDescription
editChannelModalTitlestringHeader label object.
editChannelNameLabelstringLabel above channel name field.
editChannelDescriptionLabelstringLabel above channel description field.
editChannelNamePlaceholderstringVisual blank string literal.
editChannelDescriptionPlaceholderstringTarget context neatly rendering element.
editChannelPublicLabelstringToggle tag identifier.
editChannelSaveLabelstringAction confirm prompt.
editChannelCancelLabelstringAbort sequence trigger.
editChannelSavingLabelstringLoading state alert.
editChannelChangeAvatarLabelstringUpload button identifier.
editChannelImageAcceptstringHTML accept attribute.
editChannelMaxImageSizenumberFile truncation threshold.
editChannelMaxImageSizeErrorstringWarning notification value.

General Context Localization

PropTypeDescription
actionsSearchLabelstringMenu action label.
actionsSettingsLabelstringConfiguration tag text.
actionsDeleteLabelstringWarning action item.
actionsLeaveLabelstringLogout list element.
actionsBlockLabelstringSecurity constraint alert.
actionsUnblockLabelstringRescind security notification.

Example

import { ChannelInfo } from '@ermis-network/ermis-chat-react';

export const SettingsSidebar = () => (
<ChannelInfo
title="Overview"
onClose={() => console.log('Close clicked')}
actionsSearchLabel="Find Messages"
onLeaveChannel={() => alert("Are you sure you want to exit?")}
/>
);

<CreateChannelModal />

A standalone modal component that handles the creation of Direct messages and Group channels seamlessly.

Core Configs

PropTypeDescription
isOpenbooleanControls whether the modal is visible.
onClose() => voidEvent triggered when closing the modal or canceling.
onSuccess(channel: Channel) => voidEvent executed when a channel is successfully created.

Component Overrides

PropTypeDescription
AvatarComponentReact.ComponentType<AvatarProps>Override standard avatar graphics.
UserItemComponentReact.ComponentType<UserPickerItemProps>Individual user mapping row element override in the user picker.

Localization (I18n)

PropTypeDescription
titlestringModal header title text (default: 'New Message').
directTabLabelstringLabel for Direct messaging tab.
groupTabLabelstringLabel for Group channel tab.
groupNameLabelstringLabel above the channel name field.
groupNamePlaceholderstringHint text for channel name.
groupDescriptionLabelstringLabel above the description field.
groupDescriptionPlaceholderstringHint text for description.
groupPublicLabelstringAssociated label for the channel visibility toggle.
userSearchPlaceholderstringPlaceholder for the user search input.
cancelButtonLabelstringText for the cancel action button.
createButtonLabelstringText for the create channel submit button.
creatingButtonLabelstringLoading state text for the submit button.
messageButtonLabelstringLabel for the action button when opening an existing direct message.

Example

import { useState } from 'react';
import { CreateChannelModal } from '@ermis-network/ermis-chat-react';

export const Navbar = () => {
const [isModalOpen, setModalOpen] = useState(false);

return (
<>
<button onClick={() => setModalOpen(true)}>Create Channel</button>

<CreateChannelModal
isOpen={isModalOpen}
onClose={() => setModalOpen(false)}
onSuccess={(channel) => {
console.log('Channel generated:', channel.id);
setModalOpen(false);
}}
title="Start a Chat"
/>
</>
);
};