reactjsreact-reduxserver-side-renderinghtml-renderingnext.js

Render formatted (unminified) HTML in React (SSR with Next.js)


How can I render formatted (unminified) HTML in React (SSR with Next.js)?

Expected output:

<div>
   <div>
       <input type="text" />
   </div>
</div>

Now receiving:

<div><div><input type="text"/></div></div>

TY!


Solution

  • You need to format the output before actually returning to browser. So as for nextjs, first switch to the custom server nexjs custom server and routing and walkthrough this answer for pretty printing html. Using nextjs or react SSR, this may not be possible as a built-in configurable option.