Menu

Next.js ships dangerouslySetInnerHTML twice: once in the HTML, once in the RSC payload
📰

Next.js ships dangerouslySetInnerHTML twice: once in the HTML, once in the RSC payload

DEV Community: nextjs·Mohamed Gado·10 days ago
#66WvS1TE
#devtonextjs#devto#dev#html#payload
Long article (1425 words) — no AI summary yet.
Reading 0:00
15s threshold

In the Next.js App Router, a server component that renders HTML with dangerouslySetInnerHTML sends that HTML twice: once in the page's HTML, and again, escaped as a string, in the inline React Server Components payload that hydration reads. For a long markdown article the payload copy can be bigger than the article. One of my case-study pages was 512 KB of HTML against a 520 KB budget: 181 KB of article and 280 KB of RSC payload. Sending each body only once, in the static HTML, brought that page to 262 KB without removing a word or an image.

This is Next.js 16.4 with React 19.3, statically exported. The mechanism applies to any App Router page that renders a big HTML string from a server component.

Why does the RSC payload contain my HTML?

The HTML the server sends is not all React needs. To hydrate, and to render later client-side navigations without a full load, React also needs the component tree as data: the RSC payload.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.