@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.
- package/.docs/organized/code-examples/waterfall.md +5 -3
- package/.docs/organized/code-examples/with-a2a.md +676 -0
- package/.docs/organized/code-examples/with-ag-ui.md +7 -8
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +28 -16
- package/.docs/organized/code-examples/with-artifacts.md +5 -5
- package/.docs/organized/code-examples/with-assistant-transport.md +3 -3
- package/.docs/organized/code-examples/with-chain-of-thought.md +34 -26
- package/.docs/organized/code-examples/with-cloud-standalone.md +10 -8
- package/.docs/organized/code-examples/with-cloud.md +5 -5
- package/.docs/organized/code-examples/with-custom-thread-list.md +7 -7
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +8 -8
- package/.docs/organized/code-examples/with-expo.md +571 -539
- package/.docs/organized/code-examples/with-external-store.md +3 -4
- package/.docs/organized/code-examples/with-ffmpeg.md +5 -5
- package/.docs/organized/code-examples/with-google-adk.md +353 -0
- package/.docs/organized/code-examples/with-heat-graph.md +304 -0
- package/.docs/organized/code-examples/with-langgraph.md +25 -23
- package/.docs/organized/code-examples/with-parent-id-grouping.md +4 -4
- package/.docs/organized/code-examples/with-react-hook-form.md +6 -9
- package/.docs/organized/code-examples/with-react-ink.md +265 -0
- package/.docs/organized/code-examples/with-react-router.md +10 -11
- package/.docs/organized/code-examples/with-store.md +29 -18
- package/.docs/organized/code-examples/with-tanstack.md +7 -7
- package/.docs/organized/code-examples/with-tap-runtime.md +6 -4
- package/.docs/raw/blog/2025-01-31-changelog/index.mdx +1 -1
- package/.docs/raw/blog/2026-03-launch-week/index.mdx +227 -0
- package/.docs/raw/docs/(docs)/architecture.mdx +1 -1
- package/.docs/raw/docs/(docs)/cli.mdx +14 -9
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +8 -3
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +5 -1
- package/.docs/raw/docs/(docs)/copilots/{make-assistant-readable.mdx → make-assistant-visible.mdx} +14 -5
- package/.docs/raw/docs/(docs)/copilots/model-context.mdx +11 -11
- package/.docs/raw/docs/(docs)/copilots/motivation.mdx +2 -2
- package/.docs/raw/docs/(docs)/devtools.mdx +3 -2
- package/.docs/raw/docs/(docs)/guides/attachments.mdx +9 -11
- package/.docs/raw/docs/(docs)/guides/branching.mdx +11 -6
- package/.docs/raw/docs/(docs)/guides/chain-of-thought.mdx +18 -16
- package/.docs/raw/docs/(docs)/guides/context-api.mdx +81 -43
- package/.docs/raw/docs/(docs)/guides/dictation.mdx +5 -5
- package/.docs/raw/docs/(docs)/guides/editing.mdx +16 -7
- package/.docs/raw/docs/(docs)/guides/latex.mdx +3 -0
- package/.docs/raw/docs/(docs)/guides/message-timing.mdx +2 -1
- package/.docs/raw/docs/(docs)/guides/multi-agent.mdx +173 -0
- package/.docs/raw/docs/(docs)/guides/quoting.mdx +55 -206
- package/.docs/raw/docs/(docs)/guides/speech.mdx +1 -4
- package/.docs/raw/docs/(docs)/guides/suggestions.mdx +9 -15
- package/.docs/raw/docs/(docs)/guides/tool-ui.mdx +17 -7
- package/.docs/raw/docs/(docs)/guides/tools.mdx +24 -9
- package/.docs/raw/docs/(docs)/index.mdx +3 -3
- package/.docs/raw/docs/(docs)/installation.mdx +69 -46
- package/.docs/raw/docs/(reference)/api-reference/context-providers/text-message-part-provider.mdx +20 -6
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-data-stream.mdx +24 -4
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-hook-form.mdx +1 -1
- package/.docs/raw/docs/(reference)/api-reference/integrations/vercel-ai-sdk.mdx +20 -19
- package/.docs/raw/docs/(reference)/api-reference/overview.mdx +28 -53
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +4 -4
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-modal.mdx +7 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/attachment.mdx +20 -14
- package/.docs/raw/docs/(reference)/api-reference/primitives/branch-picker.mdx +1 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +99 -45
- package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +52 -40
- package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +343 -23
- package/.docs/raw/docs/(reference)/api-reference/primitives/suggestion.mdx +4 -6
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item.mdx +4 -2
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +3 -5
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +169 -22
- package/.docs/raw/docs/(reference)/api-reference/runtimes/assistant-runtime.mdx +14 -4
- package/.docs/raw/docs/(reference)/api-reference/runtimes/attachment-runtime.mdx +15 -26
- package/.docs/raw/docs/(reference)/api-reference/runtimes/composer-runtime.mdx +39 -21
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-part-runtime.mdx +33 -9
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-runtime.mdx +48 -21
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-item-runtime.mdx +36 -7
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +30 -10
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-runtime.mdx +12 -10
- package/.docs/raw/docs/(reference)/migrations/deprecation-policy.mdx +1 -1
- package/.docs/raw/docs/(reference)/migrations/react-langgraph-v0-7.mdx +9 -4
- package/.docs/raw/docs/(reference)/migrations/v0-11.mdx +7 -5
- package/.docs/raw/docs/(reference)/migrations/v0-12.mdx +9 -7
- package/.docs/raw/docs/(reference)/migrations/v0-14.mdx +159 -0
- package/.docs/raw/docs/(reference)/react-compatibility.mdx +5 -134
- package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +89 -7
- package/.docs/raw/docs/cloud/ai-sdk.mdx +19 -5
- package/.docs/raw/docs/cloud/langgraph.mdx +13 -3
- package/.docs/raw/docs/ink/adapters.mdx +41 -0
- package/.docs/raw/docs/ink/custom-backend.mdx +203 -0
- package/.docs/raw/docs/ink/hooks.mdx +448 -0
- package/.docs/raw/docs/ink/index.mdx +239 -0
- package/.docs/raw/docs/ink/migration.mdx +140 -0
- package/.docs/raw/docs/ink/primitives.mdx +699 -0
- package/.docs/raw/docs/react-native/adapters.mdx +63 -87
- package/.docs/raw/docs/react-native/custom-backend.mdx +11 -14
- package/.docs/raw/docs/react-native/hooks.mdx +214 -232
- package/.docs/raw/docs/react-native/index.mdx +118 -159
- package/.docs/raw/docs/react-native/migration.mdx +144 -0
- package/.docs/raw/docs/react-native/primitives.mdx +431 -302
- package/.docs/raw/docs/runtimes/a2a/index.mdx +294 -0
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +9 -9
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +14 -3
- package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +53 -0
- package/.docs/raw/docs/runtimes/assistant-transport.mdx +59 -25
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +13 -6
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +138 -38
- package/.docs/raw/docs/runtimes/custom/local.mdx +184 -42
- package/.docs/raw/docs/runtimes/data-stream.mdx +92 -19
- package/.docs/raw/docs/runtimes/google-adk/index.mdx +624 -0
- package/.docs/raw/docs/runtimes/helicone.mdx +6 -6
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +38 -27
- package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +1 -1
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +15 -20
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +7 -11
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +8 -11
- package/.docs/raw/docs/runtimes/langserve.mdx +6 -7
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +18 -3
- package/.docs/raw/docs/ui/context-display.mdx +147 -0
- package/.docs/raw/docs/ui/file.mdx +5 -4
- package/.docs/raw/docs/ui/image.mdx +5 -4
- package/.docs/raw/docs/ui/markdown.mdx +3 -1
- package/.docs/raw/docs/ui/model-selector.mdx +8 -8
- package/.docs/raw/docs/ui/part-grouping.mdx +7 -10
- package/.docs/raw/docs/ui/quote.mdx +210 -0
- package/.docs/raw/docs/ui/reasoning.mdx +12 -11
- package/.docs/raw/docs/ui/sources.mdx +88 -17
- package/.docs/raw/docs/ui/streamdown.mdx +16 -7
- package/.docs/raw/docs/ui/thread-list.mdx +11 -13
- package/.docs/raw/docs/ui/thread.mdx +28 -33
- package/.docs/raw/docs/ui/tool-fallback.mdx +5 -6
- package/.docs/raw/docs/ui/tool-group.mdx +9 -8
- package/.docs/raw/docs/utilities/heat-graph.mdx +236 -0
- package/.docs/raw/docs/utilities/tw-shimmer.mdx +211 -0
- package/package.json +4 -4
- package/.docs/raw/docs/(reference)/legacy/styled/assistant-modal.mdx +0 -77
- package/.docs/raw/docs/(reference)/legacy/styled/decomposition.mdx +0 -635
- package/.docs/raw/docs/(reference)/legacy/styled/markdown.mdx +0 -77
- package/.docs/raw/docs/(reference)/legacy/styled/scrollbar.mdx +0 -72
- package/.docs/raw/docs/(reference)/legacy/styled/thread-width.mdx +0 -22
- package/.docs/raw/docs/(reference)/legacy/styled/thread.mdx +0 -77
- /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
|
-
##
|
|
6
|
+
## Quick Start
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
The fastest way to get started with assistant-ui for React Native.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
<Steps>
|
|
11
|
+
<Step>
|
|
11
12
|
|
|
12
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
23
|
+
### Configure API endpoint
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Create a `.env` file pointing to your chat API:
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
```
|
|
28
|
+
EXPO_PUBLIC_CHAT_ENDPOINT_URL="http://localhost:3000/api/chat"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
</Step>
|
|
28
32
|
<Step>
|
|
29
33
|
|
|
30
|
-
###
|
|
34
|
+
### Start the app
|
|
31
35
|
|
|
32
36
|
```sh
|
|
33
|
-
npx
|
|
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
|
-
###
|
|
59
|
+
### Setup Backend Endpoint
|
|
50
60
|
|
|
51
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
} from "
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
158
|
-
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
###
|
|
141
|
+
### Use it in your app
|
|
191
142
|
|
|
192
|
-
Wrap your app with `
|
|
143
|
+
Wrap your app with `AssistantRuntimeProvider` and build your chat UI:
|
|
193
144
|
|
|
194
145
|
```tsx title="app/index.tsx"
|
|
195
146
|
import {
|
|
196
|
-
|
|
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
|
-
<
|
|
258
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
308
259
|
<ChatScreen />
|
|
309
|
-
</
|
|
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
|
-
##
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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.
|