reactjsnext.jscontentfulrichtext

Render html content in rich text - Contentful + Next.js


I am building a website using Next.js and Contentful. Now I want to render html content something like <span style="font-size: 18px">View</span> in Contentful rich text. I am not sure if this is possible even.

Can you give me the solution to do this? Thank you in advance.


Solution

  • I did a similar solution using the @contentful/rich-text-react-renderer package. I tried to render content like the following HTML to render buttons and tips on my website.

    <div>
      <div style="width: 100%; text-align: center; font-size: 18px; font-weight: 700;">This is your journey guide!</div>
    </div>
    

    You can check more details here