Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

custom-adapters.md

34 lines1.4 KB

1---
2title: Custom Chat UI Adapters
3id: typed-headless-ui-custom-adapters
4order: 5
5description: "Build a framework adapter on @tanstack/ai-client/ui. The core is types and selectors only."
6keywords:
7 - tanstack ai
8 - createChatUI
9 - custom adapter
10 - headless ui
11---
12​
13Import `@tanstack/ai-client/ui`. Do not import it from the main client entry.
14​
15The subpath gives you:
16​
171. `selectChatUI` to match tool results and split list vs inline interrupts
182. `partTypeToKey` to turn `tool-call` into `toolCall`
193. Option types for tools, generic interrupts, and `outputSchema`
20​
21Your adapter owns:
22​
231. Native components and context
242. Native reactivity
253. Render callbacks, slots, or snippets
264. Development warnings for missing mapped keys
27​
28Do not add default markup. Do not add a new store. The app owns `useAppChat` from `createChatHook`, or `useChat` / `createChat`.
29​
30Call `selectChatUI({ messages, interrupts, inlineToolNames })`. Automatic traversal skips a `tool-result` only when `matched` is true. Keep unmatched results.
31​
32Warn once per missing runtime key in development. Each build tool detects development mode differently, so the adapter prints the warning.
33​
34See the [React](./react), [Solid](./solid), [Vue](./vue), [Svelte](./svelte), and [Remix](./remix) adapters for the public names to match: `Chat`, `Provider`, `Messages`, `Message`, `Part`, `Interrupts`, `Interrupt`, `useChatContext`, and `createChatHookContexts`.