POLPOUI

Chat

All-in-one chat widget combining ChatProvider, ChatMessages, and ChatInput.

The Chat component is the highest-level composition. It wraps ChatProvider, renders a virtualized message list via ChatMessages, and provides a default ChatInput. Use children to replace the default input or render a landing page.

Preview

Set up a REST API with Express and TypeScript

3m ago
Coder

I'll scaffold an Express + TypeScript project with a proper folder structure, error handling middleware, and a health check endpoint. Let me start by initializing the project.

Add a /api/users endpoint with CRUD operations

A minute ago
Coder
Type a message...

Import

import { Chat } from "@polpo-ai/chat";

Props

PropTypeDefaultDescription
sessionIdstringResume an existing session by ID
agentstringAgent name for completions
onSessionCreated(sessionId: string) => voidCalled when a new session is created
onUpdate() => voidCalled on each stream update
renderMessage(msg, index, isLast, isStreaming) => ReactNodeCustom message renderer
avatarReactNodeAvatar shown on assistant messages
agentNamestringDisplay name shown on assistant messages
streamdownComponentsRecord<string, unknown>built-inStreamdown component overrides for code blocks
skeletonCountnumber3Number of skeleton items while loading
inputPlaceholderstring"Type a message…"Placeholder for the default input
inputHintstringHint text below the default input
allowAttachmentsbooleantrueWhether file attachments are enabled
childrenReactNode | ((ctx: ChatRenderContext) => ReactNode)Replaces the default input; render function receives { hasMessages }
classNamestringAdditional className on the outer container

Usage

<Chat
  agent="my-agent"
  onSessionCreated={(id) => router.push(`/chat/${id}`)}
  avatar={<BotIcon />}
  agentName="Assistant"
/>

With landing page pattern

<Chat agent="my-agent">
  {({ hasMessages }) =>
    hasMessages ? <ChatInput /> : <ChatLanding greeting="Hello!" />
  }
</Chat>

On this page