跪拜 Guibai
← All articles
Next.js · Frontend · TypeScript

Zova and Next.js: Two SSR Hydration Models, and What Each Gives Up

By 濮水大叔 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Developers picking between Zova and Next.js App Router are really choosing between hiding hydration complexity inside the framework or managing Server/Client boundaries themselves. Zova's full-tree hydration works well for apps that want one component model, but it ships all component JS and delays first byte until the tree is done; App Router trades that for a steeper mental model and selective hydration.

Summary

Zova's server-side rendering is synchronous and serial: renderToString on the whole tree, no streaming. State travels in two channels, one in the head for startup-critical values and one in the body for large deferred data like query caches. The client detects hydration via a DOM attribute, then flushes a counter and forces updates on suspended instances when it hits zero.

Against Next.js Pages Router, the differences are engineering detail: Zova splits state into two channels, uses a DOM signal for hydration, exposes an onHydrated lifecycle, and pulls data through Controllers with auth built in. Against App Router, the difference is architectural: Zova hydrates the entire component tree and sends all component JS, while App Router limits hydration to Client Components and streams from Suspense boundaries.

Resource preloading also differs. Zova collects which modules actually loaded during render, then looks them up in the build manifest; App Router has a static mapping from route segment to chunks, so it can preload before rendering. Zova's module usage is dynamic, so preloading can only happen after the tree executes.

Takeaways
— Zova uses synchronous renderToString, so the server waits for the entire component tree before sending the first byte.
— State is split into two channels: __INITIAL_STATE__ in the head for startup-critical values, __INITIAL_STATE_DEFER__ in the body for large deferred data.
— Hydration is detected via a data-server-rendered attribute on the body and ends when a counter reaches zero.
— Zova replays Controller load errors on the client instead of re-fetching, ensuring server and client see the same failure.
— Attribute mismatches during hydration are tolerated by default for class, style, id, value, and boolean attributes.
— Resource preloading in Zova happens after render because module usage is dynamic; App Router can preload statically before rendering.
Conclusions

The article makes the case that Zova's choice to keep all complexity internal means developers write a single component model, but the trade-off is a larger first-screen payload and no streaming; that's a coherent philosophy, but it will feel limiting for apps that need fast TTFB.

By replaying Controller errors, Zova avoids a class of hydration mismatches that arise when client and server authentication states differ; App Router sidesteps this entirely by running data fetching only on the server.

The preloading difference shows that static mapping alone isn't enough; the real question is whether the page-chunk binding can be solved before rendering, which depends on the module loading strategy.

Concepts & terms
Hydration
Attaching event listeners and reactive state to server-rendered HTML so it becomes interactive.
React Server Components (RSC)
A React model where components run on the server, produce a serializable payload, and only client components are delivered as JS for hydration.
Flight protocol
The wire format used by React to encode RSC payloads, carrying component tree references and props.
renderToString
A synchronous server-side rendering API that returns the complete HTML string for the entire component tree.
Selective hydration
Hydrating only parts of the page (client components) while server components remain static.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗