Vue
Connect a Vue app to an AG-UI agent with CopilotKit.
@copilotkit/vue provides Vue 3 components and composables for CopilotKit. This guide gets you to a working Vue app with a chat UI talking to an AG-UI agent.
It connects to the agent directly with HttpAgent, so there's no CopilotKit runtime to stand up and nothing framework-specific to configure. The same setup works with any AG-UI-compatible agent, whether it's built on LangGraph, CrewAI, Mastra, Pydantic AI, or your own server.
Prerequisites#
- A running AG-UI-compatible agent endpoint. If you don't have one yet, pick a framework under Integrations and follow its agent setup.
- Vue 3.3+
- Node.js 18+
Getting started#
Create your Vue app#
If you don't have one already:
npm create vue@latest my-copilot-app
cd my-copilot-app
npm installInstall CopilotKit#
npm install @copilotkit/vuepnpm add @copilotkit/vueyarn add @copilotkit/vueImport the styles#
Import the package stylesheet once in your app entry. It's self-contained, so the chat renders without any other CSS.
import { createApp } from "vue";
import App from "./App.vue";
import "@copilotkit/vue/styles.css";
createApp(App).mount("#app");Connect to your agent#
Create an HttpAgent pointing at your agent endpoint, hand it to CopilotKitProvider, and drop in CopilotChat. Register the agent under the id default so the chat picks it up automatically.
<script setup lang="ts">
import { CopilotKitProvider, CopilotChat, HttpAgent } from "@copilotkit/vue/v2";
// Point this at your AG-UI-compatible agent endpoint
const agent = new HttpAgent({ url: "http://localhost:8000/" });
</script>
<template>
<CopilotKitProvider :self-managed-agents="{ default: agent }">
<div style="height: 100vh">
<CopilotChat />
</div>
</CopilotKitProvider>
</template>Pick your chat layout
CopilotChat is a full-height chat. Swap it for CopilotSidebar (a collapsible side panel) or CopilotPopup (a floating widget) for a different layout. They take the same props.
Run the app#
npm run devOpen the dev server URL (Vite prints it, usually http://localhost:5173), send a message, and you'll see it stream back from your agent.
Troubleshooting
- Chat renders unstyled: Make sure you imported
@copilotkit/vue/styles.cssin your app entry. - No response from the agent: Confirm the
urlpoints at a reachable AG-UI endpoint and that the agent is running. Check the browser network tab for the request. - CORS errors: A browser-direct connection needs the agent endpoint to allow your app's origin. Enable CORS on the agent, or put it behind the CopilotKit runtime.
Where to go next#
- Self-managed agents: securing the connection, the dev-only registration variant, and combining with a runtime.
- Connect AG-UI agents: the
HttpAgentinterface and the AG-UI protocol. - Integrations: set up the agent itself on LangGraph, CrewAI, Mastra, and other frameworks.
The composables (useAgent, useFrontendTool, useHumanInTheLoop, and more) mirror the React SDK. See the @copilotkit/vue README for the full API, slot-based customization, and Nuxt SSR setup.