React Showdown: Markdown with Embedded Components

2.3.1 · active · verified Sun Apr 19

react-showdown is a React component library designed for rendering Markdown content within React applications. It leverages the underlying Showdown.js parser, providing a robust solution for Markdown-to-HTML conversion. A key differentiator of this library is its unique capability to embed actual React components directly within Markdown text, which are then rendered seamlessly as part of the React component tree. This feature significantly enhances interactivity and modularity, moving beyond static HTML. The library, currently at stable version 2.3.1, also boasts full TypeScript support and offers extensive configuration options by supporting all Showdown extensions and flavors. While a specific release cadence isn't explicitly stated, the version history (2.0, 2.1, 2.3.1) suggests a pattern of incremental updates focused on new features and bug fixes.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates rendering basic Markdown with options and embedding a custom React component within Markdown text.

import React from 'react';
import MarkdownView from 'react-showdown';

function CustomComponent({ name }: { name: string }) {
  return <span style={{ color: 'blue', fontWeight: 'bold' }}>Hello {name}!</span>;
}

export default function App() {
  const basicMarkdown = `
# Welcome to React Showdown :wave:

This is a simple markdown example with a table and emojis.

| Header 1 | Header 2 |
|----------|----------|
| Cell A1  | Cell B1  |
| Cell A2  | Cell B2  |
`;

  const markdownWithComponent = `
# Embedding React Components

Here's a custom component: <CustomComponent name="World" />

You can pass props and define complex logic within them.
`;

  return (
    <div>
      <h2>Basic Markdown Render:</h2>
      <MarkdownView
        markdown={basicMarkdown}
        options={{ tables: true, emoji: true, simpleLineBreaks: true }}
        className="markdown-output"
      />

      <h2>Markdown with Custom Component:</h2>
      <MarkdownView
        markdown={markdownWithComponent}
        components={{ CustomComponent }}
        className="markdown-output"
      />
    </div>
  );
};

view raw JSON →