Hello,
I am using Next.js to build a website with longreads. The content of the longread is fetched from an API and rendered on the page using dangerouslySetInnerHTML. However, I have noticed that the HTML content is duplicated: it is rendered in the server-side HTML (which is expected), but it is also included in the <script> tag that Next.js sends for hydration.
This duplication negatively affects page performance because the semantic structures of the longread are parsed and processed twice — once in the HTML and once in the hydration script. In my case, seamless client-side navigation is not critical, so this duplication is unnecessary and creates overhead.
My questions are:
- Is there a way to prevent Next.js from including duplicate HTML in the hydration
<script>for this specific use case, since the content is already rendered in the HTML? - Are there any recommended approaches or best practices for rendering API-provided HTML in Next.js without incurring this duplication?
- If this is not currently possible, are there plans to support this kind of optimization in the future?
Thank you for your help and for building such an amazing framework!
Best regards, Eugene

