chatcn

Messages

The message system handles rendering, grouping, timestamps, reactions, replies, and more. Pass an array of ChatMessageData to ChatMessages and everything is handled automatically.

Basic Messages

The simplest usage: pass messages and a current user. Outgoing messages (matching currentUser.id) align right, incoming messages align left.

Today
A
Alice

Hey! Have you tried the new chat components?

Yes! They look amazing. Love the message grouping.

A
Alice

Right? And the theming system is really flexible.

Message Grouping

Consecutive messages from the same sender within a configurable time window (default: 2 minutes) are automatically grouped. Grouped messages share an avatar and have tighter spacing.

Today
Alex Chen

The PR is ready for review

Token refresh is completely rewritten

A

Much cleaner now

Nice! I'll take a look this afternoon.

Any areas I should focus on?

Reply-to Quotes

Add a replyTo object to any message to show a quoted reply above the message bubble.

Today
A
Alex

What about backwards compatibility with existing sessions?

AlexWhat about backwards compatibility with existing sessions?

We can run both token formats in parallel for 30 days, then cut over.

A
Alex

That's a great idea. Parallel validation is the safest approach.

System Messages

Set isSystem: true on a message to render it as a centered system notification. These are used for events like "user joined" or "conversation created".

Today
Alex Chen created this conversation
A
Alex Chen

Welcome to the team channel!

Sara Kim joined the conversation
S
Sara Kim

Thanks for the invite!

Date Separators

Date separators are automatically inserted between messages from different days. No configuration needed — just pass messages with different date timestamps and the separators appear.

Thursday
A
Alex

Let me know when you're free to discuss the roadmap.

Yesterday

How about tomorrow morning?

A
Alex

Perfect, 10am works for me.

Today

Great meeting today! I'll send the notes.

Message Data Shape

Each message is a ChatMessageData object with these key fields:

FieldTypeDescription
idstringUnique message identifier
senderIdstringID of the sender (matched against currentUser.id)
senderNamestringDisplay name
textstring?Message text content
timestampDate | numberWhen the message was sent
status"sending" | "sent" | "delivered" | "read" | "failed"Delivery status (outgoing only)
replyTo{ id, senderName, text }?Quoted reply reference
reactions{ emoji, userIds, count }[]?Reaction data
isSystemboolean?Render as centered system event
senderAvatarstring?URL for the sender's avatar image
readBy{ userId, name, avatar? }[]?Users who have read this message
systemEvent{ type, data? }?Structured data for system event messages
isPinnedboolean?Show pin indicator
isEditedboolean?Show edited label