useTextStream
function useTextStream(topic): {
textStreams: {
id: string;
text: string;
topic: string;
participantInfo: {
identity: string;
name: string;
isLocal: boolean;
};
streamInfo: {
topic: string;
timestamp: number;
};
}[];
};Defined in: packages/react/src/hooks/chat/useTextStream.ts:40
Note. This feature is under active development and may change based on developer feedback and real-world usage.
Parameters
| Parameter | Type |
|---|---|
topic | string |
Returns
{
textStreams: {
id: string;
text: string;
topic: string;
participantInfo: {
identity: string;
name: string;
isLocal: boolean;
};
streamInfo: {
topic: string;
timestamp: number;
};
}[];
}textStreams
textStreams: {
id: string;
text: string;
topic: string;
participantInfo: {
identity: string;
name: string;
isLocal: boolean;
};
streamInfo: {
topic: string;
timestamp: number;
};
}[];Example
// Basic — render text arriving on one topic.
const { textStreams } = useTextStream("my-topic");
return <div>{textStreams.map((textStream) => textStream.text)}</div>;
// Advanced — show topic updates beside room audio.
function NotesPanel() {
const { textStreams } = useTextStream("notes");
return (
<VoiceRoom agent={agent}>
<RoomAudioRenderer />
<ul>
{textStreams.map((textStream, index) => (
<li key={index}>{textStream.text}</li>
))}
</ul>
</VoiceRoom>
);
}