talira

react-markdown

React component to render Markdown

open sourceMITfree

react-markdown is a React component that renders Markdown safely, without dangerouslySetInnerHTML, so Markdown from users can't inject scripts. It's 100% CommonMark compliant, and GFM (tables, task lists, strikethrough, autolinks) comes with the remark-gfm plugin. You pass your own components to replace any element (a syntax-highlighted <code>, a custom <h2>), and remark and rehype plugins add math, raw HTML handling and more. It's built on the unified collective's remark and rehype, and has async and hooks variants for plugins that need them.

Problems it solves

  • render Markdown safely in a React app without dangerouslySetInnerHTML
  • show Markdown written by users in React without XSS
  • use my own React components for the headings and code blocks in rendered Markdown
  • render GitHub-flavored Markdown tables in React
  • add math and syntax highlighting to Markdown rendered in React

Features

  • safe by default: no dangerouslySetInnerHTML
  • 100% CommonMark, GFM with remark-gfm
  • custom components for any element
  • remark and rehype plugins
  • MarkdownAsync and MarkdownHooks for async plugins
  • URL transform for links and images

Capabilities

Takes pluginsplan not known

Alternatives

The same job

These do what react-markdown does.

  1. markdown-to-jsx A fast, versatile Markdown toolchain for React and more
  2. Marked A Markdown parser and compiler, built for speed
  3. markdown-it Markdown parser done right: fast and easy to extend

Compare react-markdown with the top 3