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, and see what renders differently."
6keywords:
7 - tanstack ai
8 - TextPart
9 - markdown
10 - migration
11 - breaking changes
12---
13
14`TextPart` in the React, Vue, and Solid UI packages now renders with TanStack Markdown. Pass `extensions` and `highlighter`. `remarkPlugins`, `rehypePlugins`, and `disableDefaultPlugins` are removed.
15
16This page is only for apps that import the `TextPart` component. `createChatHook` does not use it unless you pass it as `partsComponents.text`.
17
18## Upgrade
19
201. Find each `TextPart` in your code that has a plugin prop or a Solid `components` prop.
212. Replace each prop with the [prop map](#prop-map) below.
223. If you want colored code fences, follow [Syntax highlighting](#syntax-highlighting).
234. Read [Silent changes](#silent-changes). Default `<TextPart content={...} />` compiles, but some output looks different.
24
25## Prop map
26
27| Old prop | New prop |
28| --- | --- |
29| `remarkPlugins` | `extensions` (`MarkdownExtension[]` from `@tanstack/markdown`) |
30| `rehypePlugins` | `extensions` or `highlighter` |
31| `disableDefaultPlugins` | Removed. The streaming extension is always on. |
32| Solid `components` | Removed |
33| React `components` | `components` (`MarkdownComponents`: a tag-name map with normal HTML props) |
34
35A unified plugin, such as `remark-gfm` or `remark-cjk-friendly`, is not a TanStack Markdown extension. You cannot pass it through.
36
37## Replace plugin props
38
39### CJK bold
40
41TanStack Markdown parses CJK bold with no plugin. Remove the plugin:
42
43```tsx ignore
44// Before
45import { TextPart } from '@tanstack/ai-react/ui'
46import remarkCjkFriendly from 'remark-cjk-friendly'
47
48<TextPart content={content} remarkPlugins={[remarkCjkFriendly]} />
49```
50
51```tsx
52// After
53import { TextPart } from '@tanstack/ai-react/ui'
54
55export function Reply({ content }: { content: string }) {
56 return <TextPart content={content} />
57}
58```
59
60### Syntax highlighting
61
62The old stack ran `rehype-highlight`. Then `rehype-sanitize` removed the `hljs-*` classes, so fenced code already looked plain.
63
64To get colors, pass a TanStack Highlight callback. For the full steps, see [Highlight markdown code](../ui/markdown).
65
66```tsx ignore
67// Before
68<TextPart content={content} />
69```
70
71```tsx
72// After
73import { TextPart } from '@tanstack/ai-react/ui'
74import { highlightMarkdownCode } from './markdown-highlighter'
75
76export function Reply({ content }: { content: string }) {
77 return (
78 <TextPart
79 content={content}
80 highlighter={highlightMarkdownCode}
81 className="markdown-renderer"
82 />
83 )
84}
85```
86
87### Other remark or rehype plugins
88
89A unified plugin has no drop-in replacement. Write the behavior again as a TanStack Markdown extension, or do it outside `TextPart`.
90
91You cannot turn off the streaming extension.
92
93## React `components`
94
95React still accepts `components`, but the type is now `MarkdownComponents`, not the `Components` type of `react-markdown`. TanStack Markdown passes only intrinsic HTML props.
96
97A common override still type-checks, but renders wrong, because `inline` is always `undefined`:
98
99```tsx ignore
100// Before: compiles, but every code element renders as a block
101<TextPart
102 content={content}
103 components={{
104 code: ({ inline, children }) =>
105 inline ? <code>{children}</code> : <pre>{children}</pre>,
106 }}
107/>
108```
109
110```tsx
111// After
112import { TextPart } from '@tanstack/ai-react/ui'
113
114export function Reply({ content }: { content: string }) {
115 return (
116 <TextPart
117 content={content}
118 components={{
119 a: (props) => <a {...props} target="_blank" rel="noreferrer" />,
120 }}
121 />
122 )
123}
124```
125
126To tell a fence from inline code, read `className` (for example `language-ts`). Do not read `inline` or `node`.
127
128## Silent changes
129
130These changes happen with a default `<TextPart content={...} />`. You get no type error.
131
132| Input | Before | After |
133| --- | --- | --- |
134| Bare URL `https://example.com` | Auto-linked | Plain text |
135| Raw HTML such as `<br>` or `<img>` | Sanitized, then rendered | Escaped text |
136| Task list | `contains-task-list` / `task-list-item` | Checkbox on a plain `<li>` |
137| Fenced code | Plain (highlight classes removed) | Plain, with `tm-code` / `language-*` |
138| CJK bold `**…。**次` | Failed without a plugin | Works |
139
140Tables, lists, strikethrough, and fenced code still render.
141
142These things do not change:
143
144- `createChatHook` apps that render `{part.content}` themselves.
145- The import path: still `@tanstack/ai-react/ui` (or the Vue or Solid `/ui` subpath).
146- The `TextPart` data type on messages (`{ type: 'text', content }`). That is a type, not this component.
147
148## Done
149
150Your type checker passes, and your replies render with TanStack Markdown. To add colored code fences, follow [Highlight markdown code](../ui/markdown).