Usage
UseSpatiusAvatarProvider to initialize AvatarKit and LiveKit, then compose the avatar surface with SpatiusAvatarFrame, SpatiusAvatarCanvas, SpatiusAvatarLoading, SpatiusAvatarError, and SpatiusAvatarStatus.
Adding microphone controls with context
UseuseSpatiusAvatarContext() inside the provider tree when you want to drive UI from connection state or publish the local microphone into the avatar session.
SpatiusAvatarCanvas 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 Spatius avatar surface with a small set of composable shadcn-style primitives.
- Connect AvatarKit and LiveKit through
SpatiusAvatarProviderwithout 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
useSpatiusAvatarContext(). - 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)
Component Reference
Exports
SpatiusAvatarProvider
Initializes AvatarKit, connects the LiveKit-backed avatar motion stream, provides avatar state through React context, and renders remote room audio.
SpatiusAvatarFrame
Visual wrapper for the avatar canvas and overlays.
SpatiusAvatarCanvas
Mount target for AvatarView. The rendered avatar appears inside this div.
SpatiusAvatarLoading
Loading overlay shown while the avatar is initializing or connecting.
SpatiusAvatarError
Error overlay shown when avatar setup or streaming fails.
SpatiusAvatarStatus
Small status badge for the current avatar connection state.
Supported status labels:
idleinitializingconnectingconnecteddisconnectingerror
useSpatiusAvatar(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
useSpatiusAvatar() accepts the same connection and SDK props as SpatiusAvatarProvider, except for children, muted, volume, and onDisconnect.
Return value
useSpatiusAvatarContext()
Returns the current avatar state from SpatiusAvatarProvider.
- 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

