---
title: "CopilotChat"
description: "Headless chat primitive that wires an agent into context, plus a prebuilt full-screen chat UI from the /components subpath."
---
## Overview
`CopilotChat` connects an agent and exposes its conversation state to descendants. There are **two** versions, chosen by import path:
- **Headless** (`@copilotkit/react-native`) renders no UI. It wires up [`useAgent`](/reference/react-native/hooks/useAgent), manages attachments, and exposes everything through [`useCopilotChatContext`](#usecopilotchatcontext) so you build the interface from React Native views.
- **Prebuilt UI** (`@copilotkit/react-native/components`) is a ready-made full-screen chat with a message list, input bar, and optional header. See [Prebuilt UI](#prebuilt-ui).
## Headless `CopilotChat`
```tsx
import { CopilotChat, useCopilotChatContext } from "@copilotkit/react-native";
```
### Props
ID of the agent to connect to. Resolution order: `agentId` → `agentName` →
`"default"`.
**Deprecated.** Use `agentId`. Kept for backwards compatibility.
Thread ID for this chat session. When provided, the chat resumes the
specified thread instead of starting a new one.
Error handler scoped to this chat's agent. Fires in addition to the
provider-level `onError` (does not suppress it), receiving only errors whose
`context.agentId` matches this chat's agent.
Throttle interval (ms) for re-renders triggered by message changes. Overrides
the provider's `defaultThrottleMs`.
Enable and configure multimodal file attachments. Children read attachment
state and actions from [`useCopilotChatContext`](#usecopilotchatcontext). See
[`useAttachments`](/reference/react-native/hooks/useAttachments).
Your chat UI. Render React Native views that consume
[`useCopilotChatContext`](#usecopilotchatcontext).
### `useCopilotChatContext`
Call inside a `` tree to read the conversation state and actions. Throws if called outside a ``.
```tsx
function useCopilotChatContext(): CopilotChatContextValue;
```
The resolved agent instance.
Whether the agent is currently running.
The current conversation messages.
Currently selected attachments (uploading + ready).
Whether attachments are enabled for this chat.
Open the native document picker to add files.
Remove an attachment by ID.
Submit a message. Consumes ready attachments, builds the message content,
adds the user message, and runs the agent.
### Usage
```tsx
import { CopilotChat, useCopilotChatContext } from "@copilotkit/react-native";
import { useState } from "react";
import { FlatList, Text, TextInput, TouchableOpacity, View } from "react-native";
function ChatUI() {
const { messages, isRunning, submitMessage } = useCopilotChatContext();
const [text, setText] = useState("");
return (
m.content)}
keyExtractor={(m, i) => m.id ?? String(i)}
renderItem={({ item }) => (
{item.content}
)}
/>
{
submitMessage(text);
setText("");
}}
style={{ padding: 8 }}
>
Send
);
}
export function ChatScreen() {
return (
);
}
```
## Prebuilt UI
For a ready-made interface, import `CopilotChat` from the `/components` subpath. It renders a full-screen chat with a message list, input bar, optional header, and inline tool-call rendering via the [render-tool registry](/reference/react-native/hooks/useRenderTool).
```tsx
import { CopilotChat } from "@copilotkit/react-native/components";
```
### Props
The prebuilt UI components select their agent with `agentName` (not the
headless `agentId`). The two are equivalent; `agentName` is simply the prop
name the prebuilt components currently expose.
ID of the agent to connect to.
Placeholder text for the input field.
Suggestion pills shown in the empty state.
Title shown when there are no messages.
Subtitle shown when there are no messages.
Title for the optional header bar.
Whether to show the header bar.
Style override for the outermost container.
Style override for the message list container.
Style override for the input bar container.
Callback fired when the user sends a message.
Custom list component, for example `BottomSheetFlatList` when nesting inside a
bottom sheet.
When `true`, skip the `KeyboardAvoidingView` wrapper (useful when a parent
already handles the keyboard).
### Usage
```tsx
import { CopilotChat } from "@copilotkit/react-native/components";
export function ChatScreen() {
return (
);
}
```
## Related
- [`useCopilotKit`](/reference/react-native/hooks/useCopilotKit): access the runtime client directly
- [`useRenderTool`](/reference/react-native/hooks/useRenderTool): render React Native UI for agent tool calls
- [`CopilotModal`](/reference/react-native/components/CopilotModal): modal variants of the chat
- [`CopilotSidebar`](/reference/react-native/components/CopilotSidebar) · [`CopilotPopup`](/reference/react-native/components/CopilotPopup): prebuilt chrome