streamdown by vercel/streamdown
npx skills add https://github.com/vercel/streamdown --skill streamdown专为流式渲染优化的 React Markdown 渲染器。作为 react-markdown 的即插即用替代品,内置流式支持、安全性和交互式控件。
npm install streamdown
可选插件(按需安装):
npm install @streamdown/code @streamdown/mermaid @streamdown/math @streamdown/cjk
这是最常被遗漏的步骤。 Streamdown 使用 Tailwind 进行样式设计,必须扫描其分发文件。
Tailwind v4 — 添加到 globals.css:
@source "../node_modules/streamdown/dist/*.js";
仅为你已安装的包添加插件的 @source 行(省略未安装的插件可避免 Tailwind 错误)。查看插件页面获取确切路径:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
@source "../node_modules/@streamdown/code/dist/*.js";@source "../node_modules/@streamdown/cjk/dist/*.js";@source "../node_modules/@streamdown/math/dist/*.js";@source "../node_modules/@streamdown/mermaid/dist/*.js";Tailwind v3 — 添加到 tailwind.config.js:
module.exports = {
content: [
"./app/**/*.{js,ts,jsx,tsx,mdx}",
"./node_modules/streamdown/dist/*.js",
],
};
import { Streamdown } from 'streamdown';
<Streamdown>{markdown}</Streamdown>
'use client';
import { useChat } from '@ai-sdk/react';
import { Streamdown } from 'streamdown';
import { code } from '@streamdown/code';
export default function Chat() {
const { messages, input, handleInputChange, handleSubmit, isLoading } = useChat();
return (
<>
{messages.map((msg, i) => (
<Streamdown
key={msg.id}
plugins={{ code }}
caret="block"
isAnimating={isLoading && i === messages.length - 1 && msg.role === 'assistant'}
>
{msg.content}
</Streamdown>
))}
<form onSubmit={handleSubmit}>
<input value={input} onChange={handleInputChange} disabled={isLoading} />
</form>
</>
);
}
<Streamdown mode="static" plugins={{ code }}>
{content}
</Streamdown>
| 属性 | 类型 | 默认值 | 用途 |
|---|---|---|---|
children | string | — | Markdown 内容 |
mode | `"streaming" | "static"` | "streaming" |
plugins | { code?, mermaid?, math?, cjk? } | — | 功能插件 |
isAnimating | boolean | false | 流式处理指示器 |
caret | `"block" | "circle"` | — |
components | Components | — | 自定义元素覆盖 |
controls | `boolean | object` | true |
linkSafety | LinkSafetyConfig | { enabled: true } | 链接确认弹窗 |
shikiTheme | [light, dark] | ['github-light', 'github-dark'] | 代码主题 |
className | string | — | 容器类名 |
allowedElements | string[] | all | 允许的标签名 |
disallowedElements | string[] | [] | 禁止的标签名 |
allowElement | AllowElement | — | 自定义元素过滤器 |
unwrapDisallowed | boolean | false | 保留被禁止元素的子元素 |
skipHtml | boolean | false | 忽略原始 HTML |
urlTransform | UrlTransform | defaultUrlTransform | 转换/清理 URL |
完整的 API 参考,请查看 references/api.md。
| 插件 | 包 | 用途 |
|---|---|---|
| 代码 | @streamdown/code | 语法高亮(Shiki,支持 200+ 种语言) |
| Mermaid | @streamdown/mermaid | 图表(流程图、序列图等) |
| 数学 | @streamdown/math | 通过 KaTeX 支持 LaTeX(需要导入 CSS) |
| CJK | @streamdown/cjk | 中文/日文/韩文文本支持 |
数学插件需要 CSS:
import 'katex/dist/katex.min.css';
关于插件的配置详情,请查看 references/plugins.md。
以下文档提供更深入的实现细节:
从 assets/examples/ 复制并适配:
node_modules/streamdown/dist/*.js 添加 @source 指令或 content 条目katex/dist/katex.min.csscaret 属性和 isAnimating={true}isAnimating={true} 时自动禁用linkSafety={{ enabled: false }} 禁用shiki,并添加到 transpilePackagesallowedTags 不生效 — 仅适用于默认的 rehype 插件$$ 而非 $ — 默认禁用单美元符号以避免与货币符号冲突每周安装量
774
代码仓库
GitHub 星标
4.9K
首次出现
2026年2月6日
安全审计
安装于
codex717
opencode698
gemini-cli697
github-copilot694
amp670
kimi-cli667
Streaming-optimized React Markdown renderer. Drop-in replacement for react-markdown with built-in streaming support, security, and interactive controls.
npm install streamdown
Optional plugins (install only what's needed):
npm install @streamdown/code @streamdown/mermaid @streamdown/math @streamdown/cjk
This is the most commonly missed step. Streamdown uses Tailwind for styling and the dist files must be scanned.
Tailwind v4 — add to globals.css:
@source "../node_modules/streamdown/dist/*.js";
Add plugin @source lines only for packages you have installed (omitting uninstalled plugins avoids Tailwind errors). See plugin pages for exact paths:
@source "../node_modules/@streamdown/code/dist/*.js";@source "../node_modules/@streamdown/cjk/dist/*.js";@source "../node_modules/@streamdown/math/dist/*.js";@source "../node_modules/@streamdown/mermaid/dist/*.js";Tailwind v3 — add to tailwind.config.js:
module.exports = {
content: [
"./app/**/*.{js,ts,jsx,tsx,mdx}",
"./node_modules/streamdown/dist/*.js",
],
};
import { Streamdown } from 'streamdown';
<Streamdown>{markdown}</Streamdown>
'use client';
import { useChat } from '@ai-sdk/react';
import { Streamdown } from 'streamdown';
import { code } from '@streamdown/code';
export default function Chat() {
const { messages, input, handleInputChange, handleSubmit, isLoading } = useChat();
return (
<>
{messages.map((msg, i) => (
<Streamdown
key={msg.id}
plugins={{ code }}
caret="block"
isAnimating={isLoading && i === messages.length - 1 && msg.role === 'assistant'}
>
{msg.content}
</Streamdown>
))}
<form onSubmit={handleSubmit}>
<input value={input} onChange={handleInputChange} disabled={isLoading} />
</form>
</>
);
}
<Streamdown mode="static" plugins={{ code }}>
{content}
</Streamdown>
| Prop | Type | Default | Purpose |
|---|---|---|---|
children | string | — | Markdown content |
mode | `"streaming" | "static"` | "streaming" |
plugins | { code?, mermaid?, math?, cjk? } | — |
For full API reference, see references/api.md.
| Plugin | Package | Purpose |
|---|---|---|
| Code | @streamdown/code | Syntax highlighting (Shiki, 200+ languages) |
| Mermaid | @streamdown/mermaid | Diagrams (flowcharts, sequence, etc.) |
| Math | @streamdown/math | LaTeX via KaTeX (requires CSS import) |
| CJK | @streamdown/cjk | Chinese/Japanese/Korean text support |
Math requires CSS:
import 'katex/dist/katex.min.css';
For plugin configuration details, see references/plugins.md.
Use these for deeper implementation details:
Copy and adapt from assets/examples/:
@source directive or content entry for node_modules/streamdown/dist/*.jskatex/dist/katex.min.csscaret prop AND isAnimating={true} are requiredisAnimating={true}linkSafety={{ enabled: false }}Weekly Installs
774
Repository
GitHub Stars
4.9K
First Seen
Feb 6, 2026
Security Audits
Gen Agent Trust HubPassSocketWarnSnykWarn
Installed on
codex717
opencode698
gemini-cli697
github-copilot694
amp670
kimi-cli667
HeroUI v3 React 组件库 | 基于 Tailwind CSS v4 的无障碍 UI 框架
2,200 周安装
| Feature plugins |
isAnimating | boolean | false | Streaming indicator |
caret | `"block" | "circle"` | — |
components | Components | — | Custom element overrides |
controls | `boolean | object` | true |
linkSafety | LinkSafetyConfig | { enabled: true } | Link confirmation modal |
shikiTheme | [light, dark] | ['github-light', 'github-dark'] | Code themes |
className | string | — | Container class |
allowedElements | string[] | all | Tag names to allow |
disallowedElements | string[] | [] | Tag names to disallow |
allowElement | AllowElement | — | Custom element filter |
unwrapDisallowed | boolean | false | Keep children of disallowed elements |
skipHtml | boolean | false | Ignore raw HTML |
urlTransform | UrlTransform | defaultUrlTransform | Transform/sanitize URLs |
shikitranspilePackagesallowedTags not working — Only works with default rehype plugins$$ not $ — Single dollar is disabled by default to avoid currency conflicts