首页/streamdown
S

streamdown

by @vercelv1.0.0
0.0(0)

- Implement, configure, and customize Streamdown — a streaming-optimized React Markdown renderer with syntax highlighting, Mermaid diagrams, math rendering, and CJK support. Use when working with Streamdown setup, configuration, plugins, styling, security, or integration with AI streaming (e.g., Ver

Markdown RenderingReal-time ContentStreaming DataWeb DevelopmentContent DeliveryGitHub
安装方式
npx skills add vercel/streamdown --skill streamdown
compare_arrows

Before / After 效果对比

0

description 文档


name: streamdown description: >- Implement, configure, and customize Streamdown — a streaming-optimized React Markdown renderer with syntax highlighting, Mermaid diagrams, math rendering, and CJK support. Use when working with Streamdown setup, configuration, plugins, styling, security, or integration with AI streaming (e.g., Vercel AI SDK). Triggers on: (1) Installing or setting up Streamdown, (2) Configuring plugins (code, mermaid, math, cjk), (3) Styling or theming Streamdown output, (4) Integrating with AI chat/streaming, (5) Configuring security, link safety, or custom HTML tags, (6) Using carets, static mode, or custom components, (7) Troubleshooting Tailwind, Shiki, or Vite issues.

Streamdown

Streaming-optimized React Markdown renderer. Drop-in replacement for react-markdown with built-in streaming support, security, and interactive controls.

Quick Setup

1. Install

npm install streamdown

Optional plugins (install only what's needed):

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

2. Configure Tailwind CSS (Required)

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:

  • Code: @source "../node_modules/@streamdown/code/dist/*.js";
  • CJK: @source "../node_modules/@streamdown/cjk/dist/*.js";
  • Math: @source "../node_modules/@streamdown/math/dist/*.js";
  • Mermaid: @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",
  ],
};

3. Basic Usage

import { Streamdown } from 'streamdown';

<Streamdown>{markdown}</Streamdown>

4. With AI Streaming (Vercel AI SDK)

'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>
    </>
  );
}

5. Static Mode (Blogs, Docs)

<Streamdown mode="static" plugins={{ code }}>
  {content}
</Streamdown>

Key Props

| Prop | Type | Default | Purpose | |------|------|---------|---------| | children | string | — | Markdown content | | mode | "streaming" \| "static" | "streaming" | Rendering mode | | plugins | { code?, mermaid?, math?, cjk? } | — | Feature plugins | | isAnimating | boolean | false | Streaming indicator | | caret | "block" \| "circle" | — | Cursor style | | components | Components | — | Custom element overrides | | controls | boolean \| object | true | Interactive buttons | | 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 |

For full API reference, see references/api.md.

Plugin Quick Reference

| 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.

References

Use these for deeper implementation details:

Example Configurations

Copy and adapt from assets/examples/:

Common Gotchas

  1. Tailwind styles missing — Add @source directive or content entry for node_modules/streamdown/dist/*.js
  2. Math not rendering — Import katex/dist/katex.min.css
  3. Caret not showing — Both caret prop AND isAnimating={true} are required
  4. Copy buttons during streaming — Disabled automatically when isAnimating={true}
  5. Link safety modal appearing — Enabled by default; disable with linkSafety={{ enabled: false }}
  6. Shiki warning in Next.js — Install shiki explicitly, add to transpilePackages
  7. allowedTags not working — Only works with default rehype plugins
  8. Math uses $$ not $ — Single dollar is disabled by default to avoid currency conflicts

forum用户评价 (0)

发表评价

效果
易用性
文档
兼容性

暂无评价,来写第一条吧

统计数据

安装量596
评分0.0 / 5.0
版本1.0.0
更新日期2026年3月16日
对比案例0 组

用户评分

0.0(0)
5
0%
4
0%
3
0%
2
0%
1
0%

为此 Skill 评分

0.0

兼容平台

🔧Claude Code

时间线

创建2026年3月16日
最后更新2026年3月16日