react-markdown
React component for rendering markdown with customizable component handling.
3. Used by agents' projects
Dependency in 248 public GitHub projects set up for AI coding agents that we scanned (4.0%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What react-markdown does
react-markdown turns a markdown string into real React elements through a syntax tree, so it never needs <code>dangerouslySetInnerHTML</code>, and you can swap any HTML element for your own component.
react-markdown popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How react-markdown is used
- react-markdown is a dependency in 248 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (5.1% of the 4,867 JavaScript/TypeScript ones), #1 of 149 in markdown, editors and content.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 1,460; those are left out of every share on this page.
- The most used alternative in our scan is Marked (163 projects).
- Projects that use it most often also use React (99.2%), Lucide React (77.0%), remark-gfm (66.5%).
- It is more common in projects set up for Gemini CLI (7.0%) than for OpenCode (3.5%).
By coding agent
Often used with
react-markdown in practice
Strengths
The README gives three reasons to pick this over other markdown-in-React options. Others often rely on <code>dangerouslySetInnerHTML</code>, have markdown bugs, or don't let you swap elements for components. react-markdown is built to avoid all three.
A <code>components</code> prop maps tag names to your own React components. The README uses this to send code blocks to <code>react-syntax-highlighter</code>. Each component also receives the original hast <code>node</code>.
URLs go through <code>defaultUrlTransform</code> unless you pass your own <code>urlTransform</code>. The default keeps a short list of protocols and relative URLs.
Plugins go in <code>remarkPlugins</code> (markdown stage) or <code>rehypePlugins</code> (HTML stage). The README's math example pairs <code>remark-math</code> with <code>rehype-katex</code>.
Watch out for
There is no CommonJS build. The current line, <code>react-markdown@10</code>, targets Node.js 16. The README also says it works in modern browsers but not IE 11.
The default <code>Markdown</code> export is synchronous. With async plugins, use <code>MarkdownAsync</code> on the server or <code>MarkdownHooks</code> on the client.
<code>MarkdownHooks</code> relies on <code>useEffect</code> and <code>useState</code>, so output appears only after processing on the client. A <code>fallback</code> prop sets what shows in the meantime.
Render GFM (tables, tasklists, bare URLs) with remark-gfm
import React from 'react'
import {createRoot} from 'react-dom/client'
import Markdown from 'react-markdown'
import remarkGfm from 'remark-gfm'
const markdown = `Just a link: www.nasa.gov.`
createRoot(document.body).render(
<Markdown remarkPlugins={[remarkGfm]}>{markdown}</Markdown>
)More about react-markdown
Funding
- GitHub Sponsors: https://github.com/unifiedjs
- Open Collective: https://opencollective.com/unified
- thanks.dev: https://thanks.dev/u/gh/remarkjs
- 25 GitHub sponsors
Head to head
- react-markdown vs Marked used together in 31 projects
- react-markdown vs MDX used together in 13 projects
Packages around it
- lucide-react: Icon components
- tailwind-merge: Tailwind class merging
- remark-gfm: GFM plugin: tables, tasklists
- class-variance-authority: Component style variants
- tailwindcss: Utility-first CSS
- clsx: className builder
More in Markdown, editors and content
Alternatives
react-markdown This page
Fast, efficient markdown parser for converting markdown to HTML.
Write JSX directly in Markdown for rich, interactive content and documentation.
Get started
Install it.
npm install react-markdownRules for your agent
## react-markdown
- Import the default export (`import Markdown from 'react-markdown'`). The package is ESM only and needs Node.js 16+.
- Pass the markdown string as `children`. Never render markdown with `dangerouslySetInnerHTML`.
- For tables, strikethrough, tasklists or bare URLs, add `remark-gfm` to `remarkPlugins`. To pass plugin options, use `[[plugin, options]]`.
- Customize output through the `components` map (for example `code`, `a`, `h2`). Don't post-process the HTML.
- With async plugins, use `MarkdownAsync` on the server or `MarkdownHooks` on the client. Give `MarkdownHooks` a `fallback`.
- Use either `allowedElements` or `disallowedElements`, never both. Keep the default `urlTransform` unless you need different URL rules.
- When using `rehype-katex`, import `katex/dist/katex.min.css` yourself.