@assistant-ui/react-streamdown

中文文档
0.3.21发布于 2026/10/28MITTypeScriptES Module构建来源已验证近 30 天下载 135.2万

Streamdown-based markdown rendering for assistant-ui

原始使用文档
文档目录4 节
  1. When to use this
  2. Installation
  3. CSS setup
  4. Usage

@assistant-ui/react-streamdown

Streamdown-based markdown rendering for @assistant-ui/react. Drop-in replacement for @assistant-ui/react-markdown with built-in Shiki, KaTeX, and Mermaid support, optimized for AI streaming output.

When to use this

PackageBest for
@assistant-ui/react-markdownLightweight rendering; bring your own syntax highlighter.
@assistant-ui/react-streamdownFeature-rich with built-in Shiki, KaTeX, and Mermaid.
@assistant-ui/react-syntax-highlighterPair with react-markdown when you only need code-block highlighting.

Installation

npm install @assistant-ui/react @assistant-ui/react-streamdown

For optional features:

npm install @streamdown/code @streamdown/math @streamdown/mermaid @streamdown/cjk

CSS setup

Streamdown ships its control buttons (code-block toolbar, mermaid fullscreen) and the streaming caret as Tailwind utility classes. Tailwind v4 does not scan node_modules by default, so add a @source directive for Streamdown (and one per installed plugin) to the same stylesheet that imports Tailwind:

@import "tailwindcss";

@source "../node_modules/streamdown/dist/*.js";
@source "../node_modules/@streamdown/code/dist/*.js";
@source "../node_modules/@streamdown/math/dist/*.js";
@source "../node_modules/@streamdown/mermaid/dist/*.js";
@source "../node_modules/@streamdown/cjk/dist/*.js";

Adjust the relative path to your project's node_modules. In a pnpm or Turbo monorepo with hoisted dependencies, you typically need more ../ segments to reach the workspace root. Only keep the plugin lines for packages you actually installed.

Without these directives, the copy, download, and fullscreen buttons render unstyled, and the caret indicator stays invisible.

If you use the animated prop or createAnimatePlugin for word-level fade-in, also import the keyframes once at your app entry:

import "streamdown/styles.css";

For details on the shadcn/ui design tokens Streamdown expects, see the Streamdown README.

Usage

import { StreamdownTextPrimitive } from "@assistant-ui/react-streamdown";
import { code } from "@streamdown/code";
import { math } from "@streamdown/math";
import { mermaid } from "@streamdown/mermaid";
import "katex/dist/katex.min.css";

export const MarkdownText = () => (
  <StreamdownTextPrimitive
    plugins={{ code, math, mermaid }}
    shikiTheme={["github-light", "github-dark"]}
  />
);

Full prop reference, plugin docs, performance guide, and react-markdown migration notes at assistant-ui.com/docs/guides/streamdown.

版本与发布记录

@assistant-ui/react-streamdown 共发布 35 个版本,首次发布于 2026/01/29;过去 12 个月发布了 35 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.3.21latest2026/10/2810 天前
0.3.202026/10/0929 天前
0.3.192026/10/061 个月前
0.3.182026/10/021 个月前
0.3.172026/09/241 个月前
0.3.162026/09/181 个月前

关于 @assistant-ui/react-streamdown 的常见问题

@assistant-ui/react-streamdown 是什么?

Streamdown-based markdown rendering for assistant-ui

如何安装 @assistant-ui/react-streamdown?

在项目目录运行 npm install @assistant-ui/react-streamdown,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18 || ^19)、@assistant-ui/react(^0.15.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@assistant-ui/react-streamdown 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@assistant-ui/react-streamdown 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@assistant-ui/react-streamdown 可以商用吗?

@assistant-ui/react-streamdown 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@assistant-ui/react-streamdown 的下载量有多少?

根据 npm 官方下载统计,@assistant-ui/react-streamdown 在 2026/10/07 – 2026/11/05 这 30 天内被下载 1,351,993 次,日均约 45,066 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@assistant-ui/react-streamdown 还在维护吗?

最新版本 0.3.21 发布于 2026/10/28(10 天前);至今共发布 35 个版本,其中过去 12 个月发布了 35 个;首次发布于 2026/01/29。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。