On this page

Getting started

npm install @react-markdown-kit/renderer
import Markdown from '@react-markdown-kit/renderer'


export function Article({ content }: { content: string }) {
  return <Markdown>{content}</Markdown>
}

That's all you need to get started. There's no provider to wrap your app in and no stylesheet to import.

The renderer, running on this page
Markdown (edit me)
Rendered

Release notes

We shipped two things this week.

  1. A faster importer
  2. A changelog

Thanks for the reports.

The right-hand pane is a real Markdown component, server-rendered with the rest of the page. If you edit the source, it re-renders as you type.

What you get by default#

You get CommonMark, parsed with micromark instead of regular expressions.

Raw HTML isn't executed and unsafe URL schemes are blocked. See Security.

The output is plain semantic HTML without classes or inline styles, so your own CSS applies to it directly. See Styling.

The renderer entry doesn't have "use client", so it works in server components and static rendering. See Server rendering.

Turn on GitHub Flavored Markdown#

import { GfmMarkdown } from '@react-markdown-kit/renderer/gfm'


<GfmMarkdown>{content}</GfmMarkdown>
Tables, task lists and strikethrough
Markdown
| Item | Status |
| --- | --- |
| Importer | done |
| Exporter | ~~blocked~~ |

- [x] Ship the parser
- [ ] Ship the writer
Rendered
ItemStatus
Importerdone
Exporterblocked
  • Ship the parser
  • Ship the writer

Tables, task lists, strikethrough, autolinks and footnotes are covered in GFM.

Use your own components#

<Markdown components={{ a: AppLink, img: AppImage, code: CodeBlock }}>
  {content}
</Markdown>

You can replace any element. The override gets the element's props plus its source node. See Components.

Add editing#

The editor is a separate package, and the renderer doesn't depend on it.

npm install @react-markdown-kit/editor
'use client'


import { useState } from 'react'
import { MarkdownEditor } from '@react-markdown-kit/editor'


export function Notes() {
  const [value, setValue] = useState('# Notes\n\nStart writing.')
  return <MarkdownEditor value={value} onChange={setValue} />
}
Loading editor

What you store is plain Markdown (there's no editor JSON format to keep around). See Editor basics.

Personalize the same document#

The variables plugin fills in typed values while the renderer parses the document.

import { variables } from '@react-markdown-kit/variables'


<Markdown extensions={[variables({ data: { user: { name: 'Chatis' } } })]}>{'# Hello {{user.name}}'}</Markdown>

See Variables.

Where to go next#

You want toRead
Replace elements with your own componentsComponents
Tables, task lists, footnotesGFM
One Markdown dialect for the whole appPresets
Parse once, render many timesCompiling
Add rich editingEditor basics
Know what editing does to your sourceRound-trip preservation
Present Markdown as slidesSlides
Move off react-markdownCompatibility

Last updated on