Open History to see the last commit
1---
2title: TextPart markdown
3id: migrate-text-part-markdown
4order: 6
5description: "Move TextPart off remarkPlugins and rehypePlugins onto TanStack Markdown."
6keywords:
7 - tanstack ai
8 - TextPart
9 - markdown
10 - migration
11 - breaking changes
12---
13
14> **TL;DR:** This is a breaking change. `TextPart` no longer accepts `remarkPlugins`, `rehypePlugins`, or `disableDefaultPlugins`. Pass `extensions` and `highlighter` instead. Default `<TextPart content={...} />` still type-checks. Bare URLs stay plain text. Raw HTML in the model is escaped.
15
16`TextPart` from `@tanstack/ai-react/ui`, `@tanstack/ai-vue/ui`, and `@tanstack/ai-solid/ui` now renders with [TanStack Markdown](https://tanstack.com/markdown).
17
18This page is only for people who already import that component. `createChatHook` does not use it unless you pass it as `partsComponents.text`. Deprecated `ChatMessage` still prints plain text.
19
20## Who this hits
21
22- You passed `remarkPlugins`, `rehypePlugins`, or `disableDefaultPlugins`. Type-check fails.
23- You passed Solid `components`. Type-check fails. React `components` stays, with a new type.
24- You used default `TextPart` with only `content`. It compiles. Output can look different (see [Silent changes](#silent-changes)).
25
26## Prop map
27
28| Old prop | New prop |
29| --- | --- |
30| `remarkPlugins` | `extensions` (`MarkdownExtension[]` from `@tanstack/markdown`) |
31| `rehypePlugins` | `extensions` or `highlighter` |
32| `disableDefaultPlugins` | gone. The streaming extension is always on |
33| Solid `components` | gone |
34| React `components` | `components` (`MarkdownComponents`: a tag-name map with normal HTML props) |
35
36A unified plugin such as `remark-gfm` or `remark-cjk-friendly` is not a TanStack Markdown extension. You cannot pass it through.
37
38## Replace plugin props
39
40### CJK bold
41
42TanStack Markdown parses CJK bold with no plugin.
43
44```tsx ignore
45import { TextPart } from '@tanstack/ai-react/ui'
46import remarkCjkFriendly from 'remark-cjk-friendly'
47
48<TextPart content={content} remarkPlugins={[remarkCjkFriendly]} />
49```
50
51```tsx
52import { TextPart } from '@tanstack/ai-react/ui'
53
54export function Reply({ content }: { content: string }) {
55 return <TextPart content={content} />
56}
57```
58
59### Syntax highlighting
60
61The old stack ran `rehype-highlight`, then `rehype-sanitize` stripped the `hljs-*` classes. Fenced code already looked plain.
62
63To get colors now, pass a TanStack Highlight callback. Full steps: [Highlight markdown code](../ui/markdown).
64
65```tsx ignore
66<TextPart content={content} />
67```
68
69```tsx
70import { TextPart } from '@tanstack/ai-react/ui'
71import { highlightMarkdownCode } from './markdown-highlighter'
72
73export function Reply({ content }: { content: string }) {
74 return (
75 <TextPart
76 content={content}
77 highlighter={highlightMarkdownCode}
78 className="markdown-renderer"
79 />
80 )
81}
82```
83
84### Extra remark or rehype plugins
85
86There is no drop-in for a unified plugin. Rewrite the behavior as a TanStack Markdown `extension`, or handle it outside `TextPart`.
87
88`disableDefaultPlugins` is gone. You cannot turn off the streaming extension.
89
90## React `components`
91
92React still accepts `components`. The type is no longer `react-markdown` `Components`. TanStack Markdown passes intrinsic HTML props only.
93
94A common override still type-checks, then mis-renders. `inline` is always `undefined`.
95
96```tsx ignore
97<TextPart
98 content={content}
99 components={{
100 code: ({ inline, children }) =>
101 inline ? <code>{children}</code> : <pre>{children}</pre>,
102 }}
103/>
104```
105
106```tsx
107import { TextPart } from '@tanstack/ai-react/ui'
108
109export function Reply({ content }: { content: string }) {
110 return (
111 <TextPart
112 content={content}
113 components={{
114 a: (props) => <a {...props} target="_blank" rel="noreferrer" />,
115 }}
116 />
117 )
118}
119```
120
121Branch on `className` (for example `language-ts`) if you need fence vs inline. Do not read `inline` or `node`.
122
123## Silent changes
124
125These happen with default `<TextPart content={...} />`. There is no type error.
126
127| Input | Before | After |
128| --- | --- | --- |
129| Bare URL `https://example.com` | Auto-linked | Plain text |
130| Raw HTML such as `<br>` or `<img>` | Sanitized, then rendered | Escaped text |
131| Task list | `contains-task-list` / `task-list-item` | Checkbox on a plain `<li>` |
132| Fenced code | Plain (highlight classes stripped) | Plain, with `tm-code` / `language-*` |
133| CJK bold `**…。**次` | Failed without a plugin | Works |
134
135Tables, lists, strikethrough, and fenced code still render.
136
137## What does not change
138
139- `createChatHook` apps that render `{part.content}` themselves.
140- Deprecated `ChatMessage` text output (plain text).
141- Import path: still `@tanstack/ai-react/ui` (or Vue / Solid `/ui`).
142- The `TextPart` data type on messages (`{ type: 'text', content }`). That is not this component.
143
144When the type error is gone and you want colored fences, follow [Highlight markdown code](../ui/markdown).