Connect any A2A v1.0 protocol-compliant agent server to a React chat UI with assistant-ui — full streaming, tool calls, and message metadata supported.
@assistant-ui/react-a2a is a runtime adapter for the A2A (Agent-to-Agent) v1.0 protocol. Use it when your backend speaks A2A; the adapter handles the wire protocol so you can focus on the UI.
When to use it
Pick the A2A runtime when:
- You have an A2A v1.0 compatible agent server, or you are building one and want a reference client.
- You want streaming task state, artifacts, and the protocol's full state machine surfaced in the UI.
- You need multi-tenant or extension-aware A2A clients.
If your backend is not A2A-compliant, see picking a runtime for alternatives.
Quickstart
You need an A2A v1.0 compatible agent server and React 18 or 19 (React Ink needs React 19).
Install
npm install @assistant-ui/react @assistant-ui/react-a2anpx expo install @assistant-ui/react-native @assistant-ui/react-a2anpm install @assistant-ui/react-ink @assistant-ui/react-a2a ink reactWire up the runtime provider
"use client";
import { AssistantRuntimeProvider } from "@assistant-ui/react";
import { useA2ARuntime } from "@assistant-ui/react-a2a";
export function MyRuntimeProvider({
children,
}: {
children: React.ReactNode;
}) {
const runtime = useA2ARuntime({
baseUrl: "http://localhost:9999",
});
return (
<AssistantRuntimeProvider runtime={runtime}>
{children}
</AssistantRuntimeProvider>
);
}import { AssistantRuntimeProvider } from "@assistant-ui/react-native";
import { useA2ARuntime } from "@assistant-ui/react-a2a";
const A2A_URL = process.env.EXPO_PUBLIC_A2A_URL ?? "http://localhost:9999";
export function MyRuntimeProvider({
children,
}: {
children: React.ReactNode;
}) {
const runtime = useA2ARuntime({
baseUrl: A2A_URL,
});
return (
<AssistantRuntimeProvider runtime={runtime}>
{children}
</AssistantRuntimeProvider>
);
}On a phone or an Android emulator, localhost is the device itself. Set EXPO_PUBLIC_A2A_URL in .env to an address the device can reach: your computer's LAN address, such as http://192.168.1.20:9999, or http://10.0.2.2:9999 from the Android emulator. The iOS simulator can use localhost. For a LAN address, the agent server has to listen on that interface (for example on 0.0.0.0), not only on localhost.
import { AssistantRuntimeProvider } from "@assistant-ui/react-ink";
import { useA2ARuntime } from "@assistant-ui/react-a2a";
export function MyRuntimeProvider({
children,
}: {
children: React.ReactNode;
}) {
const runtime = useA2ARuntime({
baseUrl: "http://localhost:9999",
});
return (
<AssistantRuntimeProvider runtime={runtime}>
{children}
</AssistantRuntimeProvider>
);
}Render the Thread
import { Thread } from "@/components/assistant-ui/elements/thread.aui";
import { MyRuntimeProvider } from "./MyRuntimeProvider";
export default function Page() {
return (
<MyRuntimeProvider>
<Thread />
</MyRuntimeProvider>
);
}import { View } from "react-native";
import { Thread } from "@/components/assistant-ui/elements/thread.aui";
import { MyRuntimeProvider } from "@/runtime/MyRuntimeProvider";
export default function Page() {
return (
<MyRuntimeProvider>
<View style={{ flex: 1 }}>
<Thread />
</View>
</MyRuntimeProvider>
);
}import { Box } from "ink";
import { Thread } from "./components/thread.js";
import { MyRuntimeProvider } from "./runtime/MyRuntimeProvider.js";
export function App() {
return (
<MyRuntimeProvider>
<Box flexDirection="column">
<Thread />
</Box>
</MyRuntimeProvider>
);
}Set up UI components
Follow the UI Components guide to wire up the Thread, composer, and supporting primitives.
Follow the React Native setup to add a native Thread, composer, and supporting primitives.
Follow the Ink setup to add a terminal Thread, composer, and supporting primitives.
Once your A2A server is reachable, the runtime negotiates streaming vs non-streaming based on the agent card's capabilities.streaming flag and starts forwarding messages.
Auth and headers
Pass static or dynamic headers when your server expects auth:
const runtime = useA2ARuntime({
baseUrl: "http://localhost:9999",
headers: async () => ({
Authorization: `Bearer ${await getAccessToken()}`,
}),
});Adding adapters
Attachments, speech, feedback, history, and a custom thread list are supported through the standard adapter slots. See adapters for the contracts; pass them on useA2ARuntime:
const runtime = useA2ARuntime({
baseUrl: "http://localhost:9999",
adapters: { attachments, history, speech, feedback },
});For multi-thread, see threads and pass adapters.threadList.
A2UI surfaces and stored conversations
The runtime recognizes A2UI operation DataParts by an a2ui media type on the part or its metadata, or by the operation shape itself. It folds operations from status updates, agent messages, task snapshots, and artifacts into one surface state for the assistant message. Each renderable surface becomes a present tool call with id a2ui:<surfaceId>, so it renders through the same setup as A2UI over AG-UI. A deleted surface disappears, and the original DataPart is not rendered as JSON or sent back to the agent.
When you use a history adapter, the assistant message keeps the task data needed to restore what the user saw. Surface parts carry replayable operations in their tool artifact, and merged task artifacts live under metadata.custom.a2a.artifacts, with inline file bytes (raw) left out so a large file cannot push the message past a store's size limit; URLs, text, data, media types and file names are kept:
{
metadata: {
custom: {
a2a: {
artifacts: [{ artifactId: "report", parts: [{ text: "..." }] }],
},
},
},
}The Assistant Cloud history adapter has update, so a task paused for input_required or auth_required writes its assistant question to history. Other history adapters record the question only when they expose update; an append-only adapter stores only the settled assistant message.