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 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.
children
string | React.ReactNode
The markdown content to render. Can be a string of markdown or React nodes.
parseIncompleteMarkdown
boolean
Whether to parse and fix incomplete markdown syntax (e.g., unclosed code blocks or lists).
Default: true
className
string
CSS class names to apply to the wrapper div element.
components
object
Custom React components to use for rendering markdown elements (e.g., custom heading, paragraph, code block components).
allowedImagePrefixes
string[]
Array of allowed URL prefixes for images. Use ["*"] to allow all images.
Default: ["*"]
allowedLinkPrefixes
string[]
Array of allowed URL prefixes for links. Use ["*"] to allow all links.
Default: ["*"]
defaultOrigin
string
Default origin to use for relative URLs in links and images.
rehypePlugins
array
Array of rehype plugins to use for processing HTML. Includes KaTeX for math rendering by default.
Default: [rehypeKatex]
remarkPlugins
array
Array of remark plugins to use for processing markdown. Includes GitHub Flavored Markdown and math support by default.
Default: [remarkGfm, remarkMath]
Try Streamdown today and take your AI-powered streaming to the next level.
npx ai-elements add response
npx ai-elements@latest add response