ViteHub is still experimental. Expect bugs and breaking changes.

Chat

Render an AI SDK-native message list without coupling presentation to transport.

AgentChat accepts AI SDK UIMessage[] and ChatStatus. It renders messages, preserves reader scroll intent during streaming, and exposes slots for application-specific presentation.

Preview

Usage

app/pages/chat.vue
<script setup lang="ts">
import { useChat } from "@ai-sdk/vue";
import type { FileUIPart } from "ai";

const { messages, status, sendMessage, stop } = useChat();
const input = ref("");

function submit({ text, files }: { text: string; files: FileUIPart[] }) {
  sendMessage({ text, files });
  input.value = "";
}
</script>

<template>
  <div class="grid h-dvh grid-rows-[1fr_auto]">
    <AgentChat :messages :status />
    <AgentChatPrompt v-model="input" :status @submit="submit" @stop="stop" />
  </div>
</template>

ViteHub's useChat() wrapper has the same UI boundary and supplies the ViteHub route and typed Agent metadata.

Anatomy

<AgentChat>
  <template #message="{ message, index }" />
  <template #scroll-button />
</AgentChat>

Props

PropTypeDefault
messagesreadonly UIMessage[][]
statusChatStatus'ready'
edgeThresholdnumberGlobal default 8
previousItemPeeknumberGlobal default 64

The component does not call sendMessage(), stop(), or regenerate(). Keeping transport outside the rendering tree lets the same UI work with AI SDK, ViteHub Agent routes, persisted sessions, or replayed fixtures.