← all repositories
vercel/streamdown

Vercel's fix for Markdown that breaks mid-sentence

A React component that renders incomplete AI-generated Markdown without the visual chaos.

5.3k stars TypeScript Other AI
streamdown
Velocity · 7d
+18
★ / day
Trend
steady
star history

What it does

Streamdown swaps in for react-markdown when you’re piping token-by-token output from an LLM into a UI. The problem it solves: Markdown syntax often arrives half-finished—an unclosed code fence, a table missing its final row, a LaTeX block with no terminator. Standard renderers hiccup; Streamdown uses a parser called remend to keep the layout stable while tokens are still in flight.

The interesting bit

The hard part isn’t rendering Markdown; it’s rendering wrong Markdown gracefully. Vercel built this for its own AI SDK’s Message component, then spun it out as a standalone package. The memoized rendering and rehype-harden security layer suggest they learned from production chat UIs that get hammered with untrusted, fragmentary content.

Key highlights

  • Drop-in replacement for react-markdown with GFM, math (KaTeX), Mermaid diagrams, and Shiki code highlighting
  • Plugin architecture: code, math, mermaid, cjk as separate installable packages
  • Requires Tailwind CSS with explicit @source paths to node_modules (monorepos need manual ../ counting)
  • Built on shadcn/ui design tokens; needs CSS custom properties or looks broken
  • Powers the AI SDK’s Message component, so it’s eating its own dogfood

Caveats

  • Setup is fiddly: Tailwind source paths, optional plugin source paths, KaTeX CSS import, shadcn variable definitions—none of it is automatic
  • The README’s “performance optimized” claim refers to memoized rendering, but no benchmarks or comparison numbers are provided

Verdict

Grab this if you’re building a chat UI with the AI SDK and have hit the jagged-edge problem of streaming Markdown. Skip it if your Markdown is already complete when it reaches the browser, or if you aren’t using Tailwind and shadcn/ui’s variable system.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.