ChatMessage
Single message renderer that dispatches to user or assistant sub-components.
ChatMessage is a dispatcher that renders ChatUserMessage or ChatAssistantMessage based on the message role. All three are exported and can be used independently.
Preview
Can you add a users table with email and role fields?
2m ago
Coder
I'll add the users table with email validation and a role enum. Let me update your schema and run the migration.
The migration has been applied successfully. Your `users` table now has `id`, `email`, `role`, `createdAt`, and `updatedAt` columns. The `email` field has a unique constraint and the `role` field defaults to `USER`.
Import
import {
ChatMessage,
ChatUserMessage,
ChatAssistantMessage,
type ChatMessageProps,
type ChatMessageItemData,
} from "@polpo-ai/chat";ChatMessageItemData
| Field | Type | Description |
|---|---|---|
id | string | Optional message ID |
role | "user" | "assistant" | Message sender role |
content | string | ContentPart[] | Text or structured content parts |
ts | string | Optional ISO timestamp |
toolCalls | ToolCallEvent[] | Optional tool call events |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
msg | ChatMessageItemData | required | The message data to render |
isLast | boolean | — | Whether this is the last message in the list |
isStreaming | boolean | — | Whether the assistant is currently streaming |
avatar | ReactNode | — | Avatar shown on assistant messages |
agentName | string | — | Display name for assistant messages |
streamdownComponents | Record<string, unknown> | — | Streamdown component overrides |
resolveFileUrl | (fileId: string) => string | /api/v1/files/read?path=<id> | Resolve file_id to a URL |
className | string | — | Additional className |
Usage
<ChatMessage
msg={{ role: "assistant", content: "Hello!" }}
isLast={true}
isStreaming={false}
avatar={<BotIcon />}
agentName="Assistant"
/>