Comark vs Streamdown
TL;DR: Streamdown is Vercel's React component for streamed LLM Markdown. Comark also completes unfinished syntax during streaming, and adds plain-text component syntax, a standalone parser with a JSON-safe document, and renderers for Vue, React, Svelte, Angular, HTML, and the terminal.
At a glance
| Comark | Streamdown | |
|---|---|---|
| Streams incomplete Markdown | Yes, auto-close on every parse | Yes, remend completes syntax before parsing |
| Custom components in content | Yes, ::alert{type="info"} syntax | No, element remapping only |
| Frameworks | Vue, React, Svelte, Angular, Nuxt, HTML, ANSI | React only |
| Parse and render split | Decoupled, AST is serializable | Coupled, rendering component |
| Syntax highlighting | Shiki plugin | Shiki plugin (@streamdown/code) |
| Math | KaTeX plugin | KaTeX plugin (@streamdown/math) |
| Mermaid | Mermaid plugin | Mermaid plugin (@streamdown/mermaid) |
| Security hardening | Security plugin | rehype-sanitize and rehype-harden on by default |
| AI SDK integration | Works with useChat and Chat in any framework | Built around @ai-sdk/react |
Same problem, different scope
LLMs stream Markdown token by token, while standard renderers expect complete documents. Both Streamdown and Comark's auto-close step close unfinished bold markers, open code fences, and partial links before each render.
The difference is scope. Streamdown is a React rendering component. Comark is a parser with renderers on top:
import { parseMarkdown } from 'comark'
// Runs on the server, in a worker, or in the browser
const tree = await parseMarkdown(partialMarkdown, { autoClose: true })That split lets you parse AI output on the server and stream the AST, cache parsed content, post-process it with the AST API, or render the same stream in a terminal with @comark/ansi.
Components in the stream
With Streamdown, the model writes standard Markdown and you map HTML tags to styled elements. With Comark, the model can also write component syntax in plain text:
Here are your flight options:
::flight-card{airline="United" from="SFO" to="JFK" price="342"}
Departs 8:15 AM, nonstop, 5h 30m.
::
Want me to book one of these?The renderer looks up flight-card in your components map and mounts your component while the message streams:
import { Markdown } from '@comark/react'
<Markdown streaming={isStreaming} components={{ FlightCard }}>
{message.text}
</Markdown>Because ::flight-card is text rather than JSX, component syntax runs no code. A tag with no registered component renders as a plain element with the same name. Add the security plugin with a blockedTags list to remove raw HTML tags such as <script> from model output.
Beyond React
Streamdown targets React only. Comark ships the same streaming behavior for Vue, React, Svelte, Angular, and Nuxt, plus string renderers for HTML and ANSI.
What Streamdown does well
- Built-in chat controls and sanitization:
rehype-sanitize,rehype-harden, copy and download buttons, table export, and link confirmation modals come preconfigured. With Comark, you add sanitization and highlighting through plugins. - Drop-in API for react-markdown users: Streamdown mirrors the
react-markdownprops API.
If you're building a React-only chat UI on @ai-sdk/react and don't need custom components in model output, Streamdown requires less setup.
FAQ
::component syntax in your system prompt, register the components in the renderer, and they render live during streaming. See streaming in React or Vue.blockedTags list to strip risky tags, unsafe URLs, and event handler attributes from untrusted output.useChat message text to <Markdown streaming> in React, or the equivalent in Vue, Svelte, and Angular. Try it live in the streaming playground.Comark vs react-markdown
Comark adds component syntax, streaming auto-close, and multi-framework rendering that react-markdown lacks. Compare architecture, component mapping, and streaming behavior.
Comark vs Markdoc
Comark and Markdoc both treat Markdown as data with runtime parsing. Comark adds streaming auto-close, a more compact AST, and renderers for Vue, Svelte, Angular, and ANSI.