页面简介
A markdown renderer designed for streaming content from AI models. Highly interactive, customizable, and easy to use.
正文摘录
StreamdownA markdown renderer designed for streaming content from AI models. Highly interactive, customizable, and easy to use.For humansFor agents$npm i streamdownA fully-loaded Markdown rendererBuilt-in typography, streaming carets, animations, plugins, and more.Typography & GFMBuilt-in Tailwind typography for headings, lists, and code blocks. GitHub Flavored Markdown adds tables, task lists, strikethrough, and autolinks.Streaming experienceBuilt-in caret indicators show users content is generating. Unterminated block styling parses incomplete Markdown for prettier streaming with smooth animations.Interactive code blocksShiki-powered syntax highlighting with copy and download buttons. Supports language detection and line numbers.Math, diagrams & CJKLaTeX math through KaTeX, interactive Mermaid diagrams with fullscreen viewing, and CJK support for correct ideographic punctuation.Security & link safetySecurity hardening blocks images and links from unexpected origins. Link safety modals display the full URL before navigation to protect users.Fully customizableOverride any element with custom components, apply your own styles, and fine-tune behavior through configuration. Tree-shakeable plugins keep your bundle lean.Get started in secondsInstall only what you need. Plugins are optional and tree-shakeable for minimal bundle size.app/chat/page.tsximport { useChat } from "@ai-sdk/react";import { Streamdown } from "streamdown";import { code } from "@streamdown/code";import { mermaid } from "@streamdown/mermaid";import { math } from "@streamdown/math";import { cjk } from "@streamdown/cjk";import "katex/dist/katex.min.css"; export default function Chat() { const { messages, status } = useChat(); return ( <div> {messages.map(message => ( <div key={message.id}> {message.role === 'user' ? 'User: ' : 'AI: '} {message.parts.map((part, index) => part.type === 'text' ? ( <Streamdown key={index} plugins={{ code, mermaid, math, cjk }} isAnimating={status === 'streaming'} > {part.text} </Streamdown> ) : null, )} </div> ))} </div> );}ShowcaseSee Streamdown in action with one of our templates.Next.js Chatbot TemplateA free, open-source template that helps you dive right into building powerful chatbot applications.AI ElementsA collection of UI elements for building AI-powered applications.Vibe Coding PlatformAn end to end text-to-app coding platform.Upgrade your AI experiencesRead the docs