Streamdown: AI-Optimized Markdown Renderer for React
-
Introduction
Streamdown is a powerful React library designed as a drop-in replacement for react-markdown, optimized for AI-powered streaming. Visit the official website to learn more.
What is Streamdown?
Streamdown enables the streaming of safe and perfectly formatted Markdown content without complex handling. It powers components like the AI Elements Response component and can be installed as a standalone package.
Key Features
- Drop-in replacement for react-markdown
- Built-in typography styles with Tailwind classes
- GitHub Flavored Markdown (GFM) support
- Interactive code blocks with Shiki highlighting
- LaTeX mathematical expressions via KaTeX
- Interactive Mermaid diagrams
- Security hardening against prompt injection
How to Use Streamdown
Install Streamdown via npm:
npm i streamdownOr use:
npx ai-elements add responseIntegrate it into your React app using the
<Response>component or the Streamdown component directly. Update your Tailwindglobals.cssto include Streamdown's styles.Use Cases
- Rendering AI-generated streaming Markdown in web apps
- Building chat interfaces for AI models
- Displaying complex Markdown with advanced features
- Secure Markdown rendering from untrusted sources
FAQ
-
How does Streamdown differ from react-markdown?
Streamdown is optimized for streaming and handles incomplete Markdown blocks gracefully. -
Does it support incomplete Markdown during streaming?
Yes, it parses and styles unterminated blocks for prettier streaming. -
How is security handled?
Streamdown includes built-in security hardening against prompt injection.
For more details, visit Streamdown's GitHub.