Skip to Content

Chat API

Chat components and types from @myco-dev/sdk/chat.

ChatPage

import { ChatPage } from "@myco-dev/sdk/chat";

Full chat experience component with message list, composer, file upload, and conversation starters.

Props: ChatPageProps

PropTypeRequiredDescription
mycoMycoSDKYesSDK instance
session{ user: { id, name, email } } | nullYesCurrent user session
chatIdstring | nullNoLoad an existing chat
setChatId(id: string) => voidNoCallback when a new chat is created
onError(error: Error) => voidNoError handler
onCopySuccess() => voidNoCallback on successful copy
onCopyError(error: unknown) => voidNoCallback on copy failure
conversationStartersArray<{ label: string; message: string }>NoSuggested prompts
componentsChatComponentsNoCustom component overrides
beforeComposerReactNodeNoContent above the input
composerPlaceholderstringNoInput placeholder text
classNamestringNoCSS class

Example

import { ChatPage } from "@myco-dev/sdk/chat"; import { useAuth } from "@myco-dev/sdk/auth"; import { myco } from "@/lib/myco"; function MyChatPage() { const { user } = useAuth(); return ( <ChatPage myco={myco} session={user ? { user: { id: user.id, name: user.name, email: user.email } } : null} conversationStarters={[ { label: "Help me", message: "What can you help me with?" }, ]} onError={(err) => console.error(err)} /> ); }

getToolIcon

import { getToolIcon } from "@myco-dev/sdk/chat";

Returns an icon component for a given tool name. Always returns a valid component (falls back to a default icon).

function getToolIcon(toolName: string): React.ComponentType

ChatComponents

Custom component overrides for ChatPage:

interface ChatComponents { Loading?: React.ComponentType; Message?: React.ComponentType<MessageSlotProps>; ToolCall?: React.ComponentType<ToolCallSlotProps>; Composer?: React.ComponentType<ComposerSlotProps>; Greeting?: React.ComponentType<GreetingSlotProps>; }

Slot props

MessageSlotProps

Props passed to custom message components.

ToolCallSlotProps

Props passed to custom tool call display components.

ComposerSlotProps

Props passed to custom composer components.

GreetingSlotProps

Props passed to custom greeting/empty state components.


Types

import type { Chat, ChatMessage } from "@myco-dev/sdk/chat";

Chat

Represents a chat conversation.

ChatMessage

Represents a single message in a chat.

These types are derived from the Myco backend schema.