Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

secondman's avatar

Debugging SSR Hydration

My app works great except it won't hydrate, any ideas on how to debug why my container is empty?

 createSerenityApp.js:29 [Vue warn]: Attempting to hydrate existing markup but container is empty. Performing full mount instead.
warn2	@	runtime-core.esm-bundler.js:40
hydrate2	@	runtime-core.esm-bundler.js:4634
mount	@	runtime-core.esm-bundler.js:4471
app.mount	@	runtime-dom.esm-bundler.js:1626
setup	@	createSerenityApp.js:29
(anonymous)	@	createInertiaApp.ts:39
Promise.then (async)		
j2	@	createInertiaApp.ts:38
createSerenityApp	@	createSerenityApp.js:11
(anonymous)	@	app.js:9

I set a breakpoint at 4634 where the hydrate error is, but I don't see how to figure out what components are causing it to fail, everything builds fine, I get a 588kb ssr.mjs file, and the server starts fine, but the container remains empty.

0 likes
2 replies
LaryAI's avatar
Level 58

The error message suggests that the container is empty, so the first step would be to check if the container element exists in the HTML. If it does not exist, then the hydration process will fail.

If the container element exists, then the next step would be to check if the server-side rendered HTML matches the client-side rendered HTML. If there are any differences, then the hydration process will fail.

To debug this issue, you can try the following steps:

  1. Check if the container element exists in the HTML.
  2. Compare the server-side rendered HTML with the client-side rendered HTML.
  3. Check if there are any errors in the console that might be preventing the hydration process from completing.
  4. Check if all the required JavaScript files are being loaded correctly.
  5. Try removing any custom components or code that might be causing the issue and see if the hydration process works without them.

Here's an example of how to compare the server-side rendered HTML with the client-side rendered HTML:

// Get the server-side rendered HTML
const ssrHtml = document.documentElement.outerHTML;

// Get the client-side rendered HTML
const csrHtml = app.$el.outerHTML;

// Compare the two HTML strings
if (ssrHtml !== csrHtml) {
  console.error('Server-side rendered HTML does not match client-side rendered HTML');
}

This will log an error message to the console if the two HTML strings do not match.

secondman's avatar

This doesn't tell me how to find the component that is causing the problem.

Please or to participate in this conversation.