Nuxt.js hydration mismatch during server-side state transfer
18.5K reputation · 24 Apr 2025, 08:20 UTC
Nuxt.js uses a universal rendering approach where the server generates initial HTML and the client hydrates the state to enable Vue.js reactivity. This process relies on a serialized state object injected into the HTML to ensure consistency between the server-rendered DOM and the client-side Vue instance.
When components rely on dynamic data via asyncData or fetch, there is a risk that the DOM structure generated on the server differs from the initial render on the client. This discrepancy typically manifests as a hydration mismatch, potentially affecting the stability of the UI during the transition to client-side interactivity.
- What specific conditions in the serialized state transfer lead to a hydration node mismatch?
- How does the Nuxt.js runtime reconcile differences when the server-side HTML contains content that the client-side logic determines should be hidden or altered immediately upon load?