Run your own code when the session connects, the avatar speaks, or an error happens.
| Prop | Type | Default | Description |
|---|---|---|---|
startOptional | () => void | No default | Session connected and is active. Safe to call speakText, play, etc. |
stopOptional | () => void | No default | Session ended. Either from stop() or a disconnection. |
speakingOptional | () => void | No default | Avatar began speaking and animating. |
interruptOptional | () => void | No default | Avatar speech was cut short via interrupt(). |
readyOptional | () => void | No default | Avatar has rendered on screen for the first time. |
errorOptional | (error: AvatarError) => void | No default | An error occurred. Check error.fatal to know whether the session survived. |
| Prop | Type | Default | Description |
|---|---|---|---|
noticeOptional | (notice: SessionNotice) => void | No default | A graceful, server-initiated message — a plan limit, a demo cap, a test key expiring. The avatar speaks it and the session then closes. Not an error. |
transcriptOptional | (entries: TranscriptEntry[]) => void | No default | The whole transcript, re-emitted as a snapshot on every change. Only fires when transcript.enabled is set. |
healthOptional | (health: ConnectionHealth) => void | No default | Connection health, re-emitted whenever the server reports stream health. Carries the per-service map and the blame-resolved concern the banner renders from. |
notice is not error. A notice means the session is ending
deliberately, and notice.message is written for your users — it is the same
text the avatar just said out loud. Drive upgrade CTAs off notice; never off
error.
useAvatarEvent handles cleanup automatically when the component unmounts.
Use when you need to subscribe outside the component lifecycle, or group multiple events in one useEffect.
Always return a cleanup function from useEffect that calls off for every on. Missing cleanup causes memory leaks and stale handlers firing after component unmount.
The error state on useAvatar is sticky: it stays set until the next start(), so you can render off it safely. The error event fires once, in real time — use useAvatarEvent("error", ...) when you need every occurrence (analytics, logging).