Using React Markdown in Next.js

Daniel Phiri
InstructorDaniel Phiri
Share this video with your friends

Social Share Links

Send Tweet

We wrote out our posts in markdown. Next.js doesn't automatically render markdown how we want it, so we are going to install and use the package react-markdown.

Instructor: [0:00] We want to be able to render Markdown in our posts. Currently, when we click to Genie by Mark Twain, we notice some of the text is not formatted. To do this, we use something called react-markdown. We'll go back home, and in our terminal, we'll stop our server, type yarn add react-markdown.

[0:23] Once react-markdown is installed, we'll start our server again with yarn dev, and go back to VS Code. Open our file explorer and open our Components, we'll open content.js. In content.js, at the top, we'll import ReactMarkdown from 'react-markdown.' We'll cut the children and say ReactMarkdown. I'll add some special formatting, dollar sign, and paste and save.

[1:09] Now, when we click to Genie, we see our content formatted. That is how we use React Markdown in Next.js 13.