Failed to render diagram: {error}
{children};
}
return {children};
}
```
You can also use `useStreamdownPreProps` to access the props passed to the parent `` element:
```tsx
import { useStreamdownPreProps } from "@assistant-ui/react-streamdown";
function MyCodeComponent({ children }) {
const preProps = useStreamdownPreProps();
if (!preProps) {
// Inline code
return {children};
}
// Block code - preProps contains className, node, etc.
return {children};
}
```
Comparison with react-markdown \[#comparison-with-react-markdown]
| Feature | react-markdown | react-streamdown |
| ------------------- | -------------- | --------------------- |
| Bundle size | Smaller | Larger (with plugins) |
| Syntax highlighting | Bring your own | Built-in Shiki |
| Math rendering | Manual setup | Built-in KaTeX |
| Mermaid diagrams | Manual setup | Built-in support |
| CJK optimization | None | Built-in |
| Streaming | `smooth` prop | `mode` + block-based |
Re-exported Utilities \[#re-exported-utilities]
The package re-exports useful utilities:
```tsx
import {
// Context for accessing streamdown state
StreamdownContext,
// Parse markdown into blocks (for custom implementations)
parseMarkdownIntoBlocks,
// Hooks for custom code components
useIsStreamdownCodeBlock,
useStreamdownPreProps,
// Memo comparison utility for custom components
memoCompareNodes,
// Default Shiki theme: ["github-light", "github-dark"]
DEFAULT_SHIKI_THEME,
} from "@assistant-ui/react-streamdown";
```
Available Types \[#available-types]
```tsx
import type {
// Component props
StreamdownTextPrimitiveProps,
SyntaxHighlighterProps,
CodeHeaderProps,
ComponentsByLanguage,
StreamdownTextComponents,
StreamdownProps,
// Plugin types
PluginConfig,
ResolvedPluginConfig,
CodeHighlighterPlugin,
DiagramPlugin,
MathPlugin,
CjkPlugin,
HighlightOptions,
// Shiki types
BundledTheme,
BundledLanguage,
// Configuration types
CaretStyle,
ControlsConfig,
MermaidOptions,
MermaidErrorComponentProps,
LinkSafetyConfig,
LinkSafetyModalProps,
RemendConfig,
RemendHandler,
AllowedTags,
RemarkRehypeOptions,
BlockProps,
SecurityConfig,
} from "@assistant-ui/react-streamdown";
```
Related Components \[#related-components]
* [Markdown](/docs/ui/markdown) - Lightweight markdown with react-markdown
* [Syntax Highlighting](/docs/ui/syntax-highlighting) - Add code highlighting to react-markdown
* [Mermaid](/docs/ui/mermaid) - Render diagrams in react-markdown