Comark vs react-markdown
TL;DR: react-markdown renders standard Markdown to React elements and maps HTML tags to components. Comark supports the same tag mapping, and adds component syntax in Markdown, autoClose for streamed LLM output, a serializable document for server parsing, and renderers for Vue, Svelte, Angular, HTML, and the terminal.
At a glance
| Comark | react-markdown | |
|---|---|---|
| Runtime parsing | Yes | Yes |
Remap h1, a, code to components | Yes, components map | Yes, components prop |
| Custom components in the content | Yes, ::alert{type="info"} | No, element remapping only |
| Streaming incomplete Markdown | autoClose completes syntax on every parse | Unclosed syntax shows raw markers until complete |
| Frameworks | Vue, React, Svelte, Angular, Nuxt, HTML, ANSI | React only |
| Parse and render split | Decoupled, parse on server and render on client | Coupled, parsing happens inside the component |
| Underlying parser | markdown-exit (markdown-it compatible) | remark (unified) |
| Plugins | Comark plugins and markdown-it plugins | remark and rehype plugins |
| Frontmatter | Parsed by default into document.frontmatter | Requires remark-frontmatter and custom handling |
Element mapping works the same way
If you use react-markdown to replace HTML elements with React components, the components prop works the same way:
import Markdown from 'react-markdown'
<Markdown
components={{
a: (props) => <Link {...props} />,
code: (props) => <CodeBlock {...props} />,
}}
>
{markdown}
</Markdown>import { Markdown } from '@comark/react'
<Markdown
components={{
a: Link,
code: CodeBlock,
}}
>
{markdown}
</Markdown>What react-markdown can't express
react-markdown maps existing HTML elements to components. It has no syntax for components without an HTML tag, such as a callout, a tabbed code group, or a video embed. Adding raw HTML with rehype-raw brings back HTML verbosity and widens the sanitization surface.
Comark defines components in Markdown:
::alert{type="warning"}
This is **Markdown** inside a component, with nested Markdown support.
::
Status: :badge[Active]{color="green"}Writers, CMS editors, and language models write plain text instead of JSX or HTML. See component syntax.
Streaming
react-markdown expects a complete document. During a token stream, unclosed asterisks, lists, and code fences render as raw text until their closing markers arrive. Vercel built Streamdown for that reason.
Auto-close completes unfinished syntax on every parse, and the streaming prop reuses completed blocks while tokens arrive:
import { Markdown } from '@comark/react'
export function Message({ text, isStreaming }: { text: string, isStreaming: boolean }) {
return <Markdown streaming={isStreaming}>{text}</Markdown>
}Decoupled parsing
react-markdown parses Markdown inside the React component on every client that renders it. Comark separates parsing from rendering so you can parse once on the server, at build time, or in a worker, and render the compact AST anywhere:
import { parseMarkdown } from 'comark'
const document = await parseMarkdown(markdown) // cache, store, or serialize as JSONimport { MarkdownDocument } from '@comark/react'
<MarkdownDocument value={document} components={{ Alert }} />The document contains tuples such as ['h1', { id: 'hello' }, 'Hello'], which serialize directly as JSON. See the document model.
What react-markdown does well
- The unified ecosystem:
react-markdownrunsremarkandrehypeplugins directly. Comark uses its own plugin API and markdown-it parsing plugins, so check that the plugins you rely on have equivalents before switching. - Safe defaults and adoption:
react-markdownstrips raw HTML by default without extra plugins, and has years of production use across React apps.
If you render complete, standard Markdown in a React-only app and rely on remark or rehype plugins, stick with react-markdown.
FAQ
comark) from @comark/react. If you parse on the server and render with <MarkdownDocument>, the parser stays out of the client bundle. react-markdown always ships its parser with the component.components map carries over. Swap the component first, then adopt ::component syntax where you need it.html plugin parses raw HTML into the document, so tags such as <script> reach the output. For untrusted content, add the security plugin with a blockedTags list. It removes blocked tags and strips unsafe URL protocols and on* attributes.comark/plugins/footnotes. See Markdown syntax.Comark vs MDX
Comark parses component syntax at runtime with no build step, while MDX compiles Markdown to JSX at build time. Compare syntax, architecture, framework support, and streaming.
Comark vs Streamdown
Streamdown streams Markdown in React. Comark streams Markdown with custom component syntax in Vue, React, Svelte, and Angular, with a decoupled parser and serializable AST.