Next.js Discord

Discord Forum

Converting a string containing markdown to HTML

Answered
Muscovy Duck posted this in #help-forum
Open in Discord
Muscovy DuckOP
Hello! I have this string that I want to render as HTML in the page:

"Testing a [link](/)."


In my component, I have this:

{(await remark()
  .use(html)
  .process(subfeature.body)).toString()}


But when rendered I see the actual lHTML (see image); what can I do to fix this?
Answered by joulev
use dangerouslySetInnerHTML
View full answer

5 Replies

Answer
(only when you trust the html is sanitised, which is already handled by remark (i think))
Muscovy DuckOP
oh right, I'll try thank you!
This is for a static website where there is no user input so there should be no risk. Thanks!
It works, wonderful thanks @joulev !