npx ai-elements add response
npx ai-elements@latest add response
A drop-in replacement for react-markdown, designed for AI-powered streaming.
npx ai-elements add response
npx ai-elements@latest add response
or install it directly with npm i streamdown
Formatting Markdown is easy, but when you tokenize and stream it, new challenges arise.
With AI Elements, we wanted a way to stream safe and perfectly formatted Markdown without having to worry about the details.
So we built Streamdown, a drop-in replacement for react-markdown, designed for AI-powered streaming.
It powers the AI Elements Response component, but you can install it as a standalone package if you want.
Streamdown comes with built-in Tailwind classes for common Markdown components — headings, lists, code blocks, and more.
Streamdown supports GitHub Flavored Markdown (GFM) out of the box, so you get things like task lists, tables, and more.
Streamdown uses Shiki to highlight code blocks, and comes with a copy button so you can easily copy the code. Hover to reveal the copy button!
Streamdown supports LaTeX math expressions through remark-math and KaTeX, enabling beautiful mathematical notation in your markdown.
Streamdown supports Mermaid diagrams with customizable themes. Current theme is "base".
Streamdown comes with built-in support for parsing unterminated Markdown blocks (# headings, `inline code`, **bold**, _italic_, [links]() and more), which makes streaming Markdown content much prettier.
Streamdown ensures that untrusted markdown does not contain images from and links to unexpected origins which might have been subject to prompt injection.
StreamdownProps extends the react-markdown component props with additional properties for streaming and security features.
All props are optional and have sensible defaults for typical use cases.
childrenstringThe markdown content to render. Can be a string of markdown or React nodes.
parseIncompleteMarkdownbooleanWhether to parse and fix incomplete markdown syntax (e.g., unclosed code blocks or lists).
Default: true
classNamestringCSS class names to apply to the wrapper div element.
componentsobjectCustom React components to use for rendering markdown elements (e.g., custom heading, paragraph, code block components).
rehypePluginsarrayArray of rehype plugins to use for processing HTML. Includes rehype-harden for security, rehype-raw for HTML support, and rehype-katex for math rendering by default. You can import defaultRehypePlugins to access individual default plugins when overriding.
Default: [[harden, { allowedImagePrefixes: ["*"], allowedLinkPrefixes: ["*"], defaultOrigin: undefined }], rehypeRaw, [rehypeKatex, { errorColor: "var(--color-muted-foreground)" }]]
remarkPluginsarrayArray of remark plugins to use for processing markdown. Includes GitHub Flavored Markdown and math support by default. You can import defaultRemarkPlugins to access individual default plugins when overriding.
Default: [[remarkGfm, {}], [remarkMath, { singleDollarTextMath: false }]]
shikiTheme[BundledTheme, BundledTheme] (from Shiki)The themes to use for code blocks. Defaults to ["github-light", "github-dark"].
Default: ["github-light", "github-dark"]
mermaidConfigMermaidConfig (from Mermaid)Custom configuration for Mermaid diagrams including theme, colors, fonts, and other rendering options. See Mermaid documentation for all available options.
controlsboolean | { table?: boolean, code?: boolean, mermaid?: boolean }Control the visibility of copy and download buttons. Can be a boolean to show/hide all controls, or an object to selectively control buttons for tables, code blocks, and Mermaid diagrams.
Default: true
isAnimatingbooleanWhether the component is currently animating. This is used to disable the copy and download buttons when the component is animating.
Default: false
Try Streamdown today and take your AI-powered streaming to the next level.
npx ai-elements add response
npx ai-elements@latest add response
Common questions about Streamdown and how it works with AI-powered streaming applications.