---
title: "Comark vs react-markdown"
description: "Comark adds component syntax, streaming auto-close, and multi-framework rendering that react-markdown lacks. Compare architecture, component mapping, and streaming behavior."
canonical_url: "https://comark.dev/compare/comark-vs-react-markdown"
---
# 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.

**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:

::code-group
```tsx [react-markdown]
import Markdown from 'react-markdown'

<Markdown
  components={{
    a: (props) => <Link {...props} />,
    code: (props) => <CodeBlock {...props} />,
  }}
>
  {markdown}
</Markdown>
```

```tsx [Comark]
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:

```mdc
::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](https://comark.dev/syntax/components).

## 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](https://comark.dev/compare/comark-vs-streamdown) for that reason.

[Auto-close](https://comark.dev/reference/auto-close) completes unfinished syntax on every parse, and the `streaming` prop reuses completed blocks while tokens arrive:

```tsx
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:

```ts [server.ts]
import { parseMarkdown } from 'comark'

const document = await parseMarkdown(markdown) // cache, store, or serialize as JSON
```

```tsx [client.tsx]
import { 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](https://comark.dev/getting-started/document-model).

## What react-markdown does well

- **The unified ecosystem**: `react-markdown` runs `remark` and `rehype` plugins directly. Comark uses its own [plugin API](https://comark.dev/plugins/custom/plugin-api) and [markdown-it parsing plugins](https://comark.dev/plugins/custom/markdown-it), so check that the plugins you rely on have equivalents before switching.
- **Safe defaults and adoption**: `react-markdown` strips 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

::accordion
  :::accordion-item{label="Is Comark heavier than react-markdown?"}
  Comark separates the parser (`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.
  :::

  :::accordion-item{label="Can I migrate incrementally?"}
  Yes. Standard Markdown parses the same way, and the `components` map carries over. Swap the component first, then adopt `::component` syntax where you need it.
  :::

  :::accordion-item{label="Does Comark sanitize HTML like react-markdown?"}
  Not by default. The default `html` plugin parses raw HTML into the document, so tags such as `<script>` reach the output. For untrusted content, add the [security plugin](https://comark.dev/plugins/built-in/security) with a `blockedTags` list. It removes blocked tags and strips unsafe URL protocols and `on*` attributes.
  :::

  :::accordion-item{label="Does Comark support GitHub Flavored Markdown?"}
  Tables, task lists, strikethrough, and autolinks are enabled by default, and footnotes are available via `comark/plugins/footnotes`. See [Markdown syntax](https://comark.dev/syntax/markdown).
  :::
::

---

- [Render in React](https://comark.dev/rendering/react)
- [Playground](https://comark.dev/play)


## Sitemap

See the full [sitemap](https://comark.dev/sitemap.md) for all pages.
