Skip to main content

AG-UI React UI Integration

@cloudbase/agent-react-ui provides chat interface components that can be directly integrated into React projects, enabling quick integration with AI Agents that conform to the AG-UI protocol. The current component is for reference only; it is recommended to use @cloudbase/agent-react-core for custom UI.

Installation

npm install @cloudbase/agent-react-core @cloudbase/agent-react-ui @cloudbase/js-sdk

Quick Start

Import styles:

import "@cloudbase/agent-react-ui/styles.css";

Usage:

import cloudbase from "@cloudbase/js-sdk";
import { AgKit, CloudBaseTransport } from "@ag-kit/react-core";
import { AgKitUI } from "@cloudbase/agent-react-ui";

const app = cloudbase.init({ env: "your-env-id" });

app.auth.signInAnonymously();

const transport = new CloudBaseTransport({
app,
agentId: "your-agent-id",
});

export function App() {
return (
<AgKit transport={transport}>
{/* AgKitUI inherits parent element width and height by default */}
<div style={{ height: "600px", width: "800px" }}>
<AgKitUI />
</div>
</AgKit>
);
}


API Reference

AgKitUI

Core chat interface component with built-in support for message rendering, tool call display, input box, and internationalization.

AgKitUIProps

OptionRequiredTypeDescription
classNameNostringClass name for the chat main layout
containerClassNameNostringClass name for the outermost root container
messagesClassNameNostringClass name for the message list area
inputClassNameNostringClass name for the input box wrapper
emptyTitleClassNameNostringClass name for the empty state title
inputPlaceholderNostringInput box placeholder text; uses locale default when not provided
suggestionsNostring[]List of suggested questions displayed when chat is empty
localeNozh-CN/enLanguage for built-in UI text, defaults to "zh-CN"
onSuggestionClickNo(suggestion: string) => voidCallback triggered when a suggested question is clicked

Example: Basic Usage

<AgKitUI />

Example: Custom Suggestions and Language

<AgKitUI
locale="zh-CN"
inputPlaceholder="输入你的问题"
suggestions={[
"帮我总结今天的工作",
"生成一份周报模板",
"解释这个接口的用途",
]}
onSuggestionClick={(value) => {
console.log("clicked suggestion:", value);
}}
/>

Example: Custom Styles

<AgKitUI
containerClassName="my-chat-container"
messagesClassName="my-messages"
inputClassName="my-input"
emptyTitleClassName="my-empty-title"
/>