Skip to main content
AvatarKit UI is a shadcn-style React component package for embedding a Spatius avatar player into your app. It wraps AvatarKit RTC setup, LiveKit session wiring, loading and error states, and a small set of presentational primitives so you can ship an avatar surface with minimal glue code.

Usage

Use SpatiusAvatarProvider to initialize AvatarKit and LiveKit, then compose the avatar surface with SpatiusAvatarFrame, SpatiusAvatarCanvas, SpatiusAvatarLoading, SpatiusAvatarError, and SpatiusAvatarStatus.
This is the same composition pattern used in the working Vite demo: an avatar frame for rendering, built-in overlays for loading and failure states, and context-driven controls for microphone and session UI.

Adding microphone controls with context

Use useSpatiusAvatarContext() 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 SpatiusAvatarProvider without 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)
Before adding this AvatarKit UI component to your project, you can use this guide to setup shadcn

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:
  • idle
  • initializing
  • connecting
  • connected
  • disconnecting
  • error

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.
Use this hook inside provider children to:
  • show or hide UI based on avatar.status
  • read the connected avatar.room for LiveKit chat and transcript components
  • call avatar.startPublishingMicrophone() and avatar.stopPublishingMicrophone()
  • invoke avatar.disconnect() or avatar.reconnect() from your own controls
useSpatiusAvatarContext() throws an error if it is used outside SpatiusAvatarProvider.