Usage
UseSpatialRealAvatarProvider to initialize AvatarKit and LiveKit, then compose the avatar surface with SpatialRealAvatarFrame, SpatialRealAvatarCanvas, SpatialRealAvatarLoading, SpatialRealAvatarError, and SpatialRealAvatarStatus.
Adding microphone controls with context
UseuseSpatialRealAvatarContext() inside the provider tree when you want to drive UI from connection state or publish the local microphone into the avatar session.
SpatialRealAvatarCanvas must render inside a container with non-zero width and height. The provider waits for the canvas container to be measurable before it starts loading the avatar.Features
- Render a SpatialReal avatar surface with a small set of composable shadcn-style primitives.
- Connect AvatarKit and LiveKit through
SpatialRealAvatarProviderwithout writing your own player wiring. - Show built-in loading, error, and connection status UI out of the box.
- Access the active LiveKit room and avatar session state through
useSpatialRealAvatarContext(). - Start, stop, reconnect, disconnect, and publish microphone audio with hook-based controls.
Installation
AvatarKit UI is built on:
- shadcn/ui conventions (local component files + Tailwind styles)
- LiveKit Agent UI ecosystem (
@livekit/components-react,@livekit/components-styles)
API Reference
Exports
SpatialRealAvatarProvider
Initializes AvatarKit, connects the LiveKit-backed avatar stream, provides avatar state through React context, and renders remote room audio.
SpatialRealAvatarFrame
Visual wrapper for the avatar canvas and overlays.
SpatialRealAvatarCanvas
Mount target for AvatarView. The rendered avatar appears inside this div.
SpatialRealAvatarLoading
Loading overlay shown while the avatar is initializing or connecting.
SpatialRealAvatarError
Error overlay shown when avatar setup or streaming fails.
SpatialRealAvatarStatus
Small status badge for the current avatar connection state.
Supported status labels:
idleinitializingconnectingconnecteddisconnectingerror
useSpatialRealAvatar(options)
Low-level hook that powers the provider. Use it when you want to wire AvatarKit into your own context or compose a custom provider.
Options
useSpatialRealAvatar() accepts the same connection and SDK props as SpatialRealAvatarProvider, except for children, muted, volume, and onDisconnect.
Return value
useSpatialRealAvatarContext()
Returns the current avatar state from SpatialRealAvatarProvider.
- show or hide UI based on
avatar.status - read the connected
avatar.roomfor LiveKit chat and transcript components - call
avatar.startPublishingMicrophone()andavatar.stopPublishingMicrophone() - invoke
avatar.disconnect()oravatar.reconnect()from your own controls

