@assistant-ui/mcp-docs-server 0.1.23 → 0.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/.docs/organized/code-examples/waterfall.md +5 -3
  2. package/.docs/organized/code-examples/with-a2a.md +676 -0
  3. package/.docs/organized/code-examples/with-ag-ui.md +7 -8
  4. package/.docs/organized/code-examples/with-ai-sdk-v6.md +28 -16
  5. package/.docs/organized/code-examples/with-artifacts.md +5 -5
  6. package/.docs/organized/code-examples/with-assistant-transport.md +3 -3
  7. package/.docs/organized/code-examples/with-chain-of-thought.md +34 -26
  8. package/.docs/organized/code-examples/with-cloud-standalone.md +10 -8
  9. package/.docs/organized/code-examples/with-cloud.md +5 -5
  10. package/.docs/organized/code-examples/with-custom-thread-list.md +7 -7
  11. package/.docs/organized/code-examples/with-elevenlabs-scribe.md +8 -8
  12. package/.docs/organized/code-examples/with-expo.md +571 -539
  13. package/.docs/organized/code-examples/with-external-store.md +3 -4
  14. package/.docs/organized/code-examples/with-ffmpeg.md +5 -5
  15. package/.docs/organized/code-examples/with-google-adk.md +353 -0
  16. package/.docs/organized/code-examples/with-heat-graph.md +304 -0
  17. package/.docs/organized/code-examples/with-langgraph.md +25 -23
  18. package/.docs/organized/code-examples/with-parent-id-grouping.md +4 -4
  19. package/.docs/organized/code-examples/with-react-hook-form.md +6 -9
  20. package/.docs/organized/code-examples/with-react-ink.md +265 -0
  21. package/.docs/organized/code-examples/with-react-router.md +10 -11
  22. package/.docs/organized/code-examples/with-store.md +29 -18
  23. package/.docs/organized/code-examples/with-tanstack.md +7 -7
  24. package/.docs/organized/code-examples/with-tap-runtime.md +6 -4
  25. package/.docs/raw/blog/2025-01-31-changelog/index.mdx +1 -1
  26. package/.docs/raw/blog/2026-03-launch-week/index.mdx +227 -0
  27. package/.docs/raw/docs/(docs)/architecture.mdx +1 -1
  28. package/.docs/raw/docs/(docs)/cli.mdx +14 -9
  29. package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +8 -3
  30. package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +5 -1
  31. package/.docs/raw/docs/(docs)/copilots/{make-assistant-readable.mdx → make-assistant-visible.mdx} +14 -5
  32. package/.docs/raw/docs/(docs)/copilots/model-context.mdx +11 -11
  33. package/.docs/raw/docs/(docs)/copilots/motivation.mdx +2 -2
  34. package/.docs/raw/docs/(docs)/devtools.mdx +3 -2
  35. package/.docs/raw/docs/(docs)/guides/attachments.mdx +9 -11
  36. package/.docs/raw/docs/(docs)/guides/branching.mdx +11 -6
  37. package/.docs/raw/docs/(docs)/guides/chain-of-thought.mdx +18 -16
  38. package/.docs/raw/docs/(docs)/guides/context-api.mdx +81 -43
  39. package/.docs/raw/docs/(docs)/guides/dictation.mdx +5 -5
  40. package/.docs/raw/docs/(docs)/guides/editing.mdx +16 -7
  41. package/.docs/raw/docs/(docs)/guides/latex.mdx +3 -0
  42. package/.docs/raw/docs/(docs)/guides/message-timing.mdx +2 -1
  43. package/.docs/raw/docs/(docs)/guides/multi-agent.mdx +173 -0
  44. package/.docs/raw/docs/(docs)/guides/quoting.mdx +55 -206
  45. package/.docs/raw/docs/(docs)/guides/speech.mdx +1 -4
  46. package/.docs/raw/docs/(docs)/guides/suggestions.mdx +9 -15
  47. package/.docs/raw/docs/(docs)/guides/tool-ui.mdx +17 -7
  48. package/.docs/raw/docs/(docs)/guides/tools.mdx +24 -9
  49. package/.docs/raw/docs/(docs)/index.mdx +3 -3
  50. package/.docs/raw/docs/(docs)/installation.mdx +69 -46
  51. package/.docs/raw/docs/(reference)/api-reference/context-providers/text-message-part-provider.mdx +20 -6
  52. package/.docs/raw/docs/(reference)/api-reference/integrations/react-data-stream.mdx +24 -4
  53. package/.docs/raw/docs/(reference)/api-reference/integrations/react-hook-form.mdx +1 -1
  54. package/.docs/raw/docs/(reference)/api-reference/integrations/vercel-ai-sdk.mdx +20 -19
  55. package/.docs/raw/docs/(reference)/api-reference/overview.mdx +28 -53
  56. package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +4 -4
  57. package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-modal.mdx +7 -1
  58. package/.docs/raw/docs/(reference)/api-reference/primitives/attachment.mdx +20 -14
  59. package/.docs/raw/docs/(reference)/api-reference/primitives/branch-picker.mdx +1 -1
  60. package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +99 -45
  61. package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +52 -40
  62. package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +343 -23
  63. package/.docs/raw/docs/(reference)/api-reference/primitives/suggestion.mdx +4 -6
  64. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item.mdx +4 -2
  65. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +3 -5
  66. package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +169 -22
  67. package/.docs/raw/docs/(reference)/api-reference/runtimes/assistant-runtime.mdx +14 -4
  68. package/.docs/raw/docs/(reference)/api-reference/runtimes/attachment-runtime.mdx +15 -26
  69. package/.docs/raw/docs/(reference)/api-reference/runtimes/composer-runtime.mdx +39 -21
  70. package/.docs/raw/docs/(reference)/api-reference/runtimes/message-part-runtime.mdx +33 -9
  71. package/.docs/raw/docs/(reference)/api-reference/runtimes/message-runtime.mdx +48 -21
  72. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-item-runtime.mdx +36 -7
  73. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +30 -10
  74. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-runtime.mdx +12 -10
  75. package/.docs/raw/docs/(reference)/migrations/deprecation-policy.mdx +1 -1
  76. package/.docs/raw/docs/(reference)/migrations/react-langgraph-v0-7.mdx +9 -4
  77. package/.docs/raw/docs/(reference)/migrations/v0-11.mdx +7 -5
  78. package/.docs/raw/docs/(reference)/migrations/v0-12.mdx +9 -7
  79. package/.docs/raw/docs/(reference)/migrations/v0-14.mdx +159 -0
  80. package/.docs/raw/docs/(reference)/react-compatibility.mdx +5 -134
  81. package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +89 -7
  82. package/.docs/raw/docs/cloud/ai-sdk.mdx +19 -5
  83. package/.docs/raw/docs/cloud/langgraph.mdx +13 -3
  84. package/.docs/raw/docs/ink/adapters.mdx +41 -0
  85. package/.docs/raw/docs/ink/custom-backend.mdx +203 -0
  86. package/.docs/raw/docs/ink/hooks.mdx +448 -0
  87. package/.docs/raw/docs/ink/index.mdx +239 -0
  88. package/.docs/raw/docs/ink/migration.mdx +140 -0
  89. package/.docs/raw/docs/ink/primitives.mdx +699 -0
  90. package/.docs/raw/docs/react-native/adapters.mdx +63 -87
  91. package/.docs/raw/docs/react-native/custom-backend.mdx +11 -14
  92. package/.docs/raw/docs/react-native/hooks.mdx +214 -232
  93. package/.docs/raw/docs/react-native/index.mdx +118 -159
  94. package/.docs/raw/docs/react-native/migration.mdx +144 -0
  95. package/.docs/raw/docs/react-native/primitives.mdx +431 -302
  96. package/.docs/raw/docs/runtimes/a2a/index.mdx +294 -0
  97. package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +9 -9
  98. package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +14 -3
  99. package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +53 -0
  100. package/.docs/raw/docs/runtimes/assistant-transport.mdx +59 -25
  101. package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +13 -6
  102. package/.docs/raw/docs/runtimes/custom/external-store.mdx +138 -38
  103. package/.docs/raw/docs/runtimes/custom/local.mdx +184 -42
  104. package/.docs/raw/docs/runtimes/data-stream.mdx +92 -19
  105. package/.docs/raw/docs/runtimes/google-adk/index.mdx +624 -0
  106. package/.docs/raw/docs/runtimes/helicone.mdx +6 -6
  107. package/.docs/raw/docs/runtimes/langgraph/index.mdx +38 -27
  108. package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +1 -1
  109. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +15 -20
  110. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +7 -11
  111. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +8 -11
  112. package/.docs/raw/docs/runtimes/langserve.mdx +6 -7
  113. package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +18 -3
  114. package/.docs/raw/docs/ui/context-display.mdx +147 -0
  115. package/.docs/raw/docs/ui/file.mdx +5 -4
  116. package/.docs/raw/docs/ui/image.mdx +5 -4
  117. package/.docs/raw/docs/ui/markdown.mdx +3 -1
  118. package/.docs/raw/docs/ui/model-selector.mdx +8 -8
  119. package/.docs/raw/docs/ui/part-grouping.mdx +7 -10
  120. package/.docs/raw/docs/ui/quote.mdx +210 -0
  121. package/.docs/raw/docs/ui/reasoning.mdx +12 -11
  122. package/.docs/raw/docs/ui/sources.mdx +88 -17
  123. package/.docs/raw/docs/ui/streamdown.mdx +16 -7
  124. package/.docs/raw/docs/ui/thread-list.mdx +11 -13
  125. package/.docs/raw/docs/ui/thread.mdx +28 -33
  126. package/.docs/raw/docs/ui/tool-fallback.mdx +5 -6
  127. package/.docs/raw/docs/ui/tool-group.mdx +9 -8
  128. package/.docs/raw/docs/utilities/heat-graph.mdx +236 -0
  129. package/.docs/raw/docs/utilities/tw-shimmer.mdx +211 -0
  130. package/package.json +4 -4
  131. package/.docs/raw/docs/(reference)/legacy/styled/assistant-modal.mdx +0 -77
  132. package/.docs/raw/docs/(reference)/legacy/styled/decomposition.mdx +0 -635
  133. package/.docs/raw/docs/(reference)/legacy/styled/markdown.mdx +0 -77
  134. package/.docs/raw/docs/(reference)/legacy/styled/scrollbar.mdx +0 -72
  135. package/.docs/raw/docs/(reference)/legacy/styled/thread-width.mdx +0 -22
  136. package/.docs/raw/docs/(reference)/legacy/styled/thread.mdx +0 -77
  137. /package/.docs/raw/docs/cloud/{overview.mdx → index.mdx} +0 -0
@@ -3,159 +3,117 @@ title: Getting Started
3
3
  description: Build AI chat interfaces for iOS and Android with @assistant-ui/react-native.
4
4
  ---
5
5
 
6
- ## Overview
6
+ ## Quick Start
7
7
 
8
- `@assistant-ui/react-native` brings assistant-ui to React Native. It provides composable primitives, reactive hooks, and a local runtime — the same layered architecture as the web package, built on native components (`View`, `TextInput`, `FlatList`, `Pressable`).
8
+ The fastest way to get started with assistant-ui for React Native.
9
9
 
10
- **Key features:**
10
+ <Steps>
11
+ <Step>
11
12
 
12
- - **Primitives** `Thread`, `Composer`, `Message`, `ThreadList`, `ThreadListItem`, `ChainOfThought`, `Suggestion`, `ActionBar`, `BranchPicker`, `Attachment` components that compose with standard React Native props
13
- - **Reactive state** — `useAuiState` with selector support for fine-grained re-renders
14
- - **Local runtime** — `useLocalRuntime` with pluggable `ChatModelAdapter` for any LLM API
15
- - **Thread management** — Multi-thread support with create, switch, rename, delete
16
- - **Tool system** — `useAssistantTool`, `makeAssistantTool` for registering tools with custom UI renderers
17
- - **Attachments** — Image and file attachments with `useComposerAddAttachment` and attachment primitives
13
+ ### Create a new project
18
14
 
19
- <Callout type="info">
20
- `@assistant-ui/react-native` shares its runtime core with `@assistant-ui/react` via `@assistant-ui/core`. The type system, state management, and runtime logic are identical — only the UI layer differs.
21
- </Callout>
15
+ ```sh
16
+ npx assistant-ui@latest create --example with-expo my-chat-app
17
+ cd my-chat-app
18
+ ```
19
+
20
+ </Step>
21
+ <Step>
22
22
 
23
- ## Getting Started
23
+ ### Configure API endpoint
24
24
 
25
- This guide uses [Expo](https://expo.dev) with the OpenAI API. You can substitute any LLM provider.
25
+ Create a `.env` file pointing to your chat API:
26
26
 
27
- <Steps>
27
+ ```
28
+ EXPO_PUBLIC_CHAT_ENDPOINT_URL="http://localhost:3000/api/chat"
29
+ ```
30
+
31
+ </Step>
28
32
  <Step>
29
33
 
30
- ### Create an Expo project
34
+ ### Start the app
31
35
 
32
36
  ```sh
33
- npx create-expo-app@latest my-chat-app
34
- cd my-chat-app
37
+ npx expo start
35
38
  ```
36
39
 
37
40
  </Step>
41
+ </Steps>
42
+
43
+ ## Manual Setup
44
+
45
+ If you prefer to add assistant-ui to an existing Expo project, follow these steps.
46
+
47
+ <Steps>
38
48
  <Step>
39
49
 
40
50
  ### Install dependencies
41
51
 
42
52
  ```sh
43
- npx expo install @assistant-ui/react-native
53
+ npx expo install @assistant-ui/react-native @assistant-ui/react-ai-sdk
44
54
  ```
45
55
 
46
56
  </Step>
47
57
  <Step>
48
58
 
49
- ### Create a ChatModelAdapter
59
+ ### Setup Backend Endpoint
50
60
 
51
- The adapter connects your LLM API to the runtime. Here's an example for the OpenAI chat completions API with streaming:
61
+ Create a backend API route using the Vercel AI SDK. This is the same endpoint you'd use with `@assistant-ui/react` on the web:
52
62
 
53
- ```tsx title="adapters/openai-chat-adapter.ts"
54
- import type {
55
- ChatModelAdapter,
56
- ChatModelRunResult,
57
- } from "@assistant-ui/react-native";
63
+ <Tabs groupId="provider" items={["OpenAI", "Anthropic", "Google"]}>
64
+
65
+ ```ts title="app/api/chat/route.ts" tab="OpenAI"
66
+ import { openai } from "@ai-sdk/openai";
67
+ import { convertToModelMessages, streamText } from "ai";
58
68
 
59
- type OpenAIModelConfig = {
60
- apiKey: string;
61
- model?: string;
62
- baseURL?: string;
63
- fetch?: typeof globalThis.fetch;
64
- };
65
-
66
- export function createOpenAIChatModelAdapter(
67
- config: OpenAIModelConfig,
68
- ): ChatModelAdapter {
69
- const {
70
- apiKey,
71
- model = "gpt-4o-mini",
72
- baseURL = "https://api.openai.com/v1",
73
- fetch: customFetch = globalThis.fetch,
74
- } = config;
75
-
76
- return {
77
- async *run({ messages, abortSignal }) {
78
- const openAIMessages = messages
79
- .filter((m) => m.role !== "system")
80
- .map((m) => ({
81
- role: m.role as "user" | "assistant",
82
- content: m.content
83
- .filter((p) => p.type === "text")
84
- .map((p) => ("text" in p ? p.text : ""))
85
- .join("\n"),
86
- }));
87
-
88
- const response = await customFetch(
89
- `${baseURL}/chat/completions`,
90
- {
91
- method: "POST",
92
- headers: {
93
- "Content-Type": "application/json",
94
- Authorization: `Bearer ${apiKey}`,
95
- },
96
- body: JSON.stringify({
97
- model,
98
- messages: openAIMessages,
99
- stream: true,
100
- }),
101
- signal: abortSignal,
102
- },
103
- );
104
-
105
- if (!response.ok) {
106
- const body = await response.text().catch(() => "");
107
- throw new Error(
108
- `OpenAI API error: ${response.status} ${body}`,
109
- );
110
- }
111
-
112
- const reader = response.body?.getReader();
113
- if (!reader) {
114
- const json = await response.json();
115
- const text = json.choices?.[0]?.message?.content ?? "";
116
- yield {
117
- content: [{ type: "text" as const, text }],
118
- } satisfies ChatModelRunResult;
119
- return;
120
- }
121
-
122
- const decoder = new TextDecoder();
123
- let fullText = "";
124
-
125
- try {
126
- while (true) {
127
- const { done, value } = await reader.read();
128
- if (done) break;
129
- const chunk = decoder.decode(value, { stream: true });
130
- for (const line of chunk.split("\n")) {
131
- if (!line.startsWith("data: ")) continue;
132
- const data = line.slice(6);
133
- if (data === "[DONE]") continue;
134
- try {
135
- const parsed = JSON.parse(data);
136
- const content =
137
- parsed.choices?.[0]?.delta?.content ?? "";
138
- fullText += content;
139
- yield {
140
- content: [
141
- { type: "text" as const, text: fullText },
142
- ],
143
- } satisfies ChatModelRunResult;
144
- } catch {
145
- // skip invalid JSON
146
- }
147
- }
148
- }
149
- } finally {
150
- reader.releaseLock();
151
- }
152
- },
153
- };
69
+ export const maxDuration = 30;
70
+
71
+ export async function POST(req: Request) {
72
+ const { messages } = await req.json();
73
+ const result = streamText({
74
+ model: openai("gpt-4o-mini"),
75
+ messages: await convertToModelMessages(messages),
76
+ });
77
+ return result.toUIMessageStreamResponse();
78
+ }
79
+ ```
80
+
81
+ ```ts title="app/api/chat/route.ts" tab="Anthropic"
82
+ import { anthropic } from "@ai-sdk/anthropic";
83
+ import { convertToModelMessages, streamText } from "ai";
84
+
85
+ export const maxDuration = 30;
86
+
87
+ export async function POST(req: Request) {
88
+ const { messages } = await req.json();
89
+ const result = streamText({
90
+ model: anthropic("claude-sonnet-4-20250514"),
91
+ messages: await convertToModelMessages(messages),
92
+ });
93
+ return result.toUIMessageStreamResponse();
94
+ }
95
+ ```
96
+
97
+ ```ts title="app/api/chat/route.ts" tab="Google"
98
+ import { google } from "@ai-sdk/google";
99
+ import { convertToModelMessages, streamText } from "ai";
100
+
101
+ export const maxDuration = 30;
102
+
103
+ export async function POST(req: Request) {
104
+ const { messages } = await req.json();
105
+ const result = streamText({
106
+ model: google("gemini-2.0-flash"),
107
+ messages: await convertToModelMessages(messages),
108
+ });
109
+ return result.toUIMessageStreamResponse();
154
110
  }
155
111
  ```
156
112
 
157
- <Callout type="tip">
158
- On Expo, import `fetch` from `expo/fetch` for streaming support and pass it as the `fetch` option.
113
+ </Tabs>
114
+
115
+ <Callout type="info">
116
+ This is the same backend you'd use with `@assistant-ui/react` on the web. If you already have an API route, you can reuse it as-is.
159
117
  </Callout>
160
118
 
161
119
  </Step>
@@ -164,36 +122,29 @@ export function createOpenAIChatModelAdapter(
164
122
  ### Set up the runtime
165
123
 
166
124
  ```tsx title="hooks/use-app-runtime.ts"
167
- import { useMemo } from "react";
168
- import { fetch } from "expo/fetch";
169
- import { useLocalRuntime } from "@assistant-ui/react-native";
170
- import { createOpenAIChatModelAdapter } from "@/adapters/openai-chat-adapter";
125
+ import { useChatRuntime, AssistantChatTransport } from "@assistant-ui/react-ai-sdk";
171
126
 
172
- export function useAppRuntime() {
173
- const chatModel = useMemo(
174
- () =>
175
- createOpenAIChatModelAdapter({
176
- apiKey: process.env.EXPO_PUBLIC_OPENAI_API_KEY ?? "",
177
- model: "gpt-4o-mini",
178
- fetch,
179
- }),
180
- [],
181
- );
127
+ const API_URL = process.env.EXPO_PUBLIC_API_URL ?? "http://localhost:3000";
182
128
 
183
- return useLocalRuntime(chatModel);
129
+ export function useAppRuntime() {
130
+ return useChatRuntime({
131
+ transport: new AssistantChatTransport({
132
+ api: `${API_URL}/api/chat`,
133
+ }),
134
+ });
184
135
  }
185
136
  ```
186
137
 
187
138
  </Step>
188
139
  <Step>
189
140
 
190
- ### Build the UI
141
+ ### Use it in your app
191
142
 
192
- Wrap your app with `AssistantProvider` — thread and composer contexts are set up automatically:
143
+ Wrap your app with `AssistantRuntimeProvider` and build your chat UI:
193
144
 
194
145
  ```tsx title="app/index.tsx"
195
146
  import {
196
- AssistantProvider,
147
+ AssistantRuntimeProvider,
197
148
  useAuiState,
198
149
  useAui,
199
150
  } from "@assistant-ui/react-native";
@@ -304,9 +255,9 @@ export default function App() {
304
255
  const runtime = useAppRuntime();
305
256
 
306
257
  return (
307
- <AssistantProvider runtime={runtime}>
258
+ <AssistantRuntimeProvider runtime={runtime}>
308
259
  <ChatScreen />
309
- </AssistantProvider>
260
+ </AssistantRuntimeProvider>
310
261
  );
311
262
  }
312
263
  ```
@@ -314,19 +265,27 @@ export default function App() {
314
265
  </Step>
315
266
  </Steps>
316
267
 
317
- ## Architecture
318
-
319
- ```
320
- useLocalRuntime(chatModel, options?)
321
- └─ AssistantProvider
322
- ├─ useAuiState((s) => s.thread) → thread state (messages, isRunning, …)
323
- ├─ useAuiState((s) => s.composer) → composer state (text, isEmpty, …)
324
- ├─ useAuiState((s) => s.message) → single message state (inside renderItem)
325
- └─ Primitives → ThreadRoot, ComposerInput, MessageContent, …
326
- ```
327
-
328
- The runtime core is shared with `@assistant-ui/react` — only the UI primitives are React Native-specific.
329
-
330
- ## Example
331
-
332
- For a complete Expo example with drawer navigation, thread list, and styled chat UI, see the [`with-expo` example](https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-expo).
268
+ ## What's Next?
269
+
270
+ <Cards>
271
+ <Card
272
+ title="Migration from Web"
273
+ description="Already using assistant-ui? Migrate your web app to React Native."
274
+ href="/docs/react-native/migration"
275
+ />
276
+ <Card
277
+ title="Custom Backend"
278
+ description="Connect to your own backend API or manage threads server-side."
279
+ href="/docs/react-native/custom-backend"
280
+ />
281
+ <Card
282
+ title="Primitives"
283
+ description="Composable native UI components for building chat interfaces."
284
+ href="/docs/react-native/primitives"
285
+ />
286
+ <Card
287
+ title="Example App"
288
+ description="Full Expo example with drawer navigation, thread list, and styled UI."
289
+ href="https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-expo"
290
+ />
291
+ </Cards>
@@ -0,0 +1,144 @@
1
+ ---
2
+ title: Migration from Web
3
+ description: Migrate an existing @assistant-ui/react app to React Native.
4
+ ---
5
+
6
+ If you already have an assistant-ui web app, most of your code transfers directly. The runtime core is shared between `@assistant-ui/react` and `@assistant-ui/react-native` via `@assistant-ui/core` — only the UI layer changes.
7
+
8
+ ## What stays the same
9
+
10
+ - **Runtime setup** — `useChatRuntime`, `useLocalRuntime`, `ChatModelAdapter`, and all runtime options work identically.
11
+ - **AI SDK integration** — `@assistant-ui/react-ai-sdk` works with React Native. Your `useChatRuntime` + `AssistantChatTransport` setup transfers directly.
12
+ - **Tool definitions** — `useAssistantTool`, `makeAssistantTool`, and tool UI renderers use the same API.
13
+ - **State hooks** — `useAuiState`, `useAui`, and selector patterns are the same.
14
+ - **Backend code** — Your API routes, streaming endpoints, and server-side logic need zero changes.
15
+
16
+ ## What changes
17
+
18
+ | Web (`@assistant-ui/react`) | React Native (`@assistant-ui/react-native`) |
19
+ |---|---|
20
+ | `AssistantRuntimeProvider` | `AssistantRuntimeProvider` (same name) |
21
+ | DOM primitives (`div`, `button`, `input`) | Native primitives (`View`, `Pressable`, `TextInput`) |
22
+ | CSS / Tailwind styling | React Native `StyleSheet` or inline styles |
23
+ | `@assistant-ui/ui` (shadcn components) | Build your own native UI with primitives |
24
+
25
+ ## Step-by-step
26
+
27
+ <Steps>
28
+ <Step>
29
+
30
+ ### Install the React Native package
31
+
32
+ ```sh
33
+ npx expo install @assistant-ui/react-native
34
+ ```
35
+
36
+ </Step>
37
+ <Step>
38
+
39
+ ### Keep your runtime hook
40
+
41
+ Your `useChatRuntime` setup works as-is — no changes needed:
42
+
43
+ ```tsx title="hooks/use-app-runtime.ts"
44
+ // This file is identical to your web version
45
+ import { useChatRuntime, AssistantChatTransport } from "@assistant-ui/react-ai-sdk";
46
+
47
+ export function useAppRuntime() {
48
+ return useChatRuntime({
49
+ transport: new AssistantChatTransport({
50
+ api: "/api/chat",
51
+ }),
52
+ });
53
+ }
54
+ ```
55
+
56
+ <Callout type="tip">
57
+ If you use a monorepo, you can share this file between web and native projects directly.
58
+ </Callout>
59
+
60
+ </Step>
61
+ <Step>
62
+
63
+ ### Replace the provider
64
+
65
+ ```tsx
66
+ // Before (web)
67
+ // import { AssistantRuntimeProvider } from "@assistant-ui/react";
68
+
69
+ // After (React Native) — same component name, different package
70
+ import { AssistantRuntimeProvider } from "@assistant-ui/react-native";
71
+
72
+ export default function App() {
73
+ const runtime = useAppRuntime();
74
+ return (
75
+ <AssistantRuntimeProvider runtime={runtime}>
76
+ {/* your native UI */}
77
+ </AssistantRuntimeProvider>
78
+ );
79
+ }
80
+ ```
81
+
82
+ </Step>
83
+ <Step>
84
+
85
+ ### Rebuild the UI layer
86
+
87
+ This is the main migration effort. Web components (`Thread`, `ThreadList` from `@assistant-ui/ui`) don't render in React Native. Replace them with native primitives:
88
+
89
+ ```tsx
90
+ // Web — DOM-based
91
+ // import { Thread } from "@/components/assistant-ui/thread";
92
+
93
+ // React Native — use primitives or build custom
94
+ import {
95
+ ThreadPrimitive,
96
+ ComposerPrimitive,
97
+ MessagePrimitive,
98
+ } from "@assistant-ui/react-native";
99
+ import { View } from "react-native";
100
+
101
+ function MyMessage() {
102
+ return (
103
+ <View style={{ padding: 12 }}>
104
+ <MessagePrimitive.Content />
105
+ </View>
106
+ );
107
+ }
108
+
109
+ function ChatScreen() {
110
+ return (
111
+ <ThreadPrimitive.Root style={{ flex: 1 }}>
112
+ <ThreadPrimitive.Messages>
113
+ {() => <MyMessage />}
114
+ </ThreadPrimitive.Messages>
115
+ <ComposerPrimitive.Root>
116
+ <ComposerPrimitive.Input placeholder="Message..." />
117
+ <ComposerPrimitive.Send />
118
+ </ComposerPrimitive.Root>
119
+ </ThreadPrimitive.Root>
120
+ );
121
+ }
122
+ ```
123
+
124
+ See the [Primitives reference](/docs/react-native/primitives) for the full list of available components.
125
+
126
+ </Step>
127
+ </Steps>
128
+
129
+ ## Monorepo code sharing
130
+
131
+ In a monorepo, you can share everything except the UI layer:
132
+
133
+ ```
134
+ packages/
135
+ shared/
136
+ hooks/ ← useAppRuntime with useChatRuntime (shared)
137
+ tools/ ← tool definitions (shared)
138
+ web/
139
+ components/ ← DOM-based UI
140
+ native/
141
+ components/ ← React Native UI
142
+ ```
143
+
144
+ The runtime hook, tool definitions, and backend code are platform-agnostic. Only the UI components need separate implementations for web and native.