import * as React from 'react'; import type { ChatOptions, ReceivedChatMessage } from '@livekit/components-core'; import { setupChat } from '@livekit/components-core'; import { ConnectionState, Room } from 'livekit-client'; import { useEnsureRoom } from '../context'; import { useObservableState } from './internal/useObservableState'; import { useConnectionState } from './useConnectionStatus'; /** * The `useChat` hook provides chat functionality for a LiveKit room. * * @remarks * Message history is not persisted and will be lost if the component is refreshed. * You may want to persist message history in the browser, a cache or a database. * * @returns An object containing: * - `chatMessages` - Array of received chat messages * - `send` - Function to send a new message * - `isSending` - Boolean indicating if a message is currently being sent * * @example * ```tsx * function ChatComponent() { * const { chatMessages, send, isSending } = useChat(); * * return ( *