@assistant-ui/vue

中文文档
0.0.7发布于 2026/10/28MITTypeScriptES Module构建来源已验证近 30 天下载 4376

Vue bindings for assistant-ui

原始使用文档
文档目录6 节
  1. Installation
  2. Usage
  3. API
  4. Without the AI SDK
  5. Documentation
  6. For other platforms

@assistant-ui/vue

npm version npm downloads GitHub stars License

Vue bindings for assistant-ui. A provider, composables, and unstyled primitives for streaming AI chat in Vue and Nuxt, running the same runtime as @assistant-ui/react.

Installation

Requires Vue 3.5 or newer.

npm install @assistant-ui/vue @assistant-ui/ai-sdk ai react

@assistant-ui/ai-sdk connects the AI SDK. It runs the AI SDK's chat state on the shared runtime, so it needs react installed even though React renders nothing.

Usage

<!-- app/components/Assistant.client.vue -->
<script setup lang="ts">
import {
  AuiConfig,
  AuiProvider,
  ComposerPrimitiveInput,
  ComposerPrimitiveSend,
  MessagePrimitiveParts,
  ThreadPrimitiveMessages,
  ThreadPrimitiveViewport,
} from "@assistant-ui/vue";
import { AISDKChat } from "@assistant-ui/ai-sdk";

const config = AuiConfig({ threads: AISDKChat() });
</script>

<template>
  <AuiProvider :config="config">
    <ThreadPrimitiveViewport class="h-dvh overflow-y-auto">
      <ThreadPrimitiveMessages>
        <MessagePrimitiveParts />
      </ThreadPrimitiveMessages>
    </ThreadPrimitiveViewport>
    <ComposerPrimitiveInput placeholder="Message..." />
    <ComposerPrimitiveSend>Send</ComposerPrimitiveSend>
  </AuiProvider>
</template>

AISDKChat() posts to /api/chat, a route that returns streamText(...).toUIMessageStreamResponse(). Mount the provider client-only, as a .client.vue component in Nuxt: Vue's server renderer never disposes effect scopes, so a provider rendered on the server would keep one runtime per request.

Styled components (thread, messages, reasoning, tool calls, thread list) install from the assistant-ui registry; the quickstart walks through them.

API

  • AuiProvider owns an assistant client built from an AuiConfig; AuiIf renders its slot while a state selector returns true.
  • useAui() returns a stable client whose scope accessors resolve to the provider's current client. useAuiState(selector) returns a computed ref that updates when the selected slice changes. useAuiEvent(event, callback) subscribes for the lifetime of the current effect scope.
  • Primitives cover threads (ThreadPrimitiveRoot, Messages, Viewport, ViewportFooter, ScrollToBottom, Suggestions), messages (MessagePrimitiveRoot, Parts, Attachments), composers (ComposerPrimitiveInput, Send, Cancel, Attachments, AddAttachment, AttachmentDropzone), attachments, branch pickers, action bars, suggestions, errors, chain of thought, and thread lists, each exported under its full name such as ThreadPrimitiveMessages.
  • Tool calls render through Vue components registered with Tools({ toolkit }) or aui.tools.setToolUI, which receive a single tool prop typed ToolUIProps; a React renderer from a toolkit shared with a React app does not render in Vue.

Without the AI SDK

To run a runtime that does not need React, such as one mounted with RuntimeAdapter from @assistant-ui/core/store, alias react to @assistant-ui/tap/standalone-shim so the shared runtime code resolves without React installed:

// vite.config.ts
export default defineConfig({
  resolve: {
    alias: {
      "react/compiler-runtime": "@assistant-ui/tap/standalone-shim/compiler-runtime",
      react: "@assistant-ui/tap/standalone-shim",
    },
  },
});

Documentation

For other platforms

版本与发布记录

@assistant-ui/vue 共发布 9 个版本,首次发布于 2026/10/06;过去 12 个月发布了 9 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.0.7latest2026/10/2810 天前
0.0.62026/10/2315 天前
0.0.52026/10/2018 天前
0.0.42026/10/1623 天前
0.0.32026/10/1128 天前
0.0.22026/10/0929 天前

关于 @assistant-ui/vue 的常见问题

@assistant-ui/vue 是什么?

Vue bindings for assistant-ui

如何安装 @assistant-ui/vue?

在项目目录运行 npm install @assistant-ui/vue,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vue(^3.5.0)、@types/react(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@assistant-ui/vue 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@assistant-ui/vue 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@assistant-ui/vue 可以商用吗?

@assistant-ui/vue 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@assistant-ui/vue 的下载量有多少?

根据 npm 官方下载统计,@assistant-ui/vue 在 2026/10/07 – 2026/11/05 这 30 天内被下载 4,376 次,日均约 146 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@assistant-ui/vue 还在维护吗?

最新版本 0.0.7 发布于 2026/10/28(10 天前);至今共发布 9 个版本,其中过去 12 个月发布了 9 个;首次发布于 2026/10/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。