Primitives

Composable React Native components for building chat UIs.

Primitives are thin wrappers around React Native components (View, TextInput, FlatList, Pressable) that integrate with the assistant-ui runtime. They accept all standard React Native props and add runtime-aware behavior.

Thread

ThreadRoot

Container View that sets up ThreadProvider and ComposerProvider contexts.

import { ThreadRoot } from "@assistant-ui/react-native";

<ThreadRoot runtime={threadRuntime} style={{ flex: 1 }}>
  {children}
</ThreadRoot>
PropTypeDescription
runtimeThreadRuntimeThe thread runtime instance
...restViewPropsStandard React Native View props

ThreadMessages

FlatList-based message list with automatic runtime integration.

import { ThreadMessages } from "@assistant-ui/react-native";

<ThreadMessages
  renderMessage={({ item }) => <MessageBubble message={item} />}
/>
PropTypeDescription
renderMessage(info: { item: ThreadMessage }) => ReactElementMessage renderer
...restFlatListPropsStandard FlatList props (except data, renderItem)

ThreadEmpty

Renders children only when the thread has no messages.

import { ThreadEmpty } from "@assistant-ui/react-native";

<ThreadEmpty>
  <Text>Send a message to get started</Text>
</ThreadEmpty>

ThreadIf

Conditional rendering based on thread state.

import { ThreadIf } from "@assistant-ui/react-native";

<ThreadIf empty>
  <Text>No messages yet</Text>
</ThreadIf>

<ThreadIf running>
  <ActivityIndicator />
</ThreadIf>
PropTypeDescription
emptybooleanRender when thread is empty
runningbooleanRender when thread is running

Composer

ComposerRoot

Container View for the composer area.

import { ComposerRoot } from "@assistant-ui/react-native";

<ComposerRoot style={styles.composerContainer}>
  {children}
</ComposerRoot>

ComposerInput

TextInput wired to the composer runtime. Value and onChangeText are managed automatically.

import { ComposerInput } from "@assistant-ui/react-native";

<ComposerInput
  placeholder="Message..."
  multiline
  style={styles.input}
/>
PropTypeDescription
...restTextInputPropsStandard TextInput props (except value, onChangeText)

ComposerSend

Pressable that sends the current message. Automatically disabled when the composer is empty.

import { ComposerSend } from "@assistant-ui/react-native";

<ComposerSend style={styles.sendButton}>
  <Text>Send</Text>
</ComposerSend>

ComposerCancel

Pressable that cancels the current run. Automatically disabled when no run is active.

import { ComposerCancel } from "@assistant-ui/react-native";

<ComposerCancel style={styles.cancelButton}>
  <Text>Stop</Text>
</ComposerCancel>

Message

MessageRoot

Container View for a single message.

import { MessageRoot } from "@assistant-ui/react-native";

<MessageRoot style={styles.messageBubble}>
  {children}
</MessageRoot>

MessageContent

Renders message content parts with customizable renderers.

import { MessageContent } from "@assistant-ui/react-native";

<MessageContent
  renderText={({ text }) => <Text>{text}</Text>}
  renderToolCall={({ toolName, args }) => (
    <Text>Tool: {toolName}</Text>
  )}
  renderImage={({ url }) => <Image source={{ uri: url }} />}
/>
PropTypeDescription
renderText(props: { text: string }) => ReactElementText part renderer
renderToolCall(props: { toolName: string; args: any }) => ReactElementTool call renderer
renderImage(props: { url: string }) => ReactElementImage part renderer

MessageIf

Conditional rendering based on message properties.

import { MessageIf } from "@assistant-ui/react-native";

<MessageIf user>
  <Text>You said:</Text>
</MessageIf>

<MessageIf assistant last>
  <ActivityIndicator />
</MessageIf>
PropTypeDescription
userbooleanRender for user messages
assistantbooleanRender for assistant messages
runningbooleanRender when message is being generated
lastbooleanRender for the last message

ThreadList

ThreadListRoot

Container View for the thread list.

import { ThreadListRoot } from "@assistant-ui/react-native";

<ThreadListRoot style={styles.threadList}>
  {children}
</ThreadListRoot>

ThreadListItems

FlatList of thread IDs with runtime integration.

import { ThreadListItems } from "@assistant-ui/react-native";

<ThreadListItems
  renderItem={({ item: threadId }) => (
    <ThreadListEntry threadId={threadId} />
  )}
/>
PropTypeDescription
renderItem(info: { item: string }) => ReactElementThread item renderer
...restFlatListPropsStandard FlatList props (except data, renderItem)

ThreadListNew

Pressable that creates a new thread.

import { ThreadListNew } from "@assistant-ui/react-native";

<ThreadListNew style={styles.newThreadButton}>
  <Text>New Chat</Text>
</ThreadListNew>