Server rendering and hydration
A single-page app ships an empty <div> and builds the page in the browser, so
the first paint waits on JavaScript. Nuxt renders your components to HTML on the
server first, so the browser shows content immediately and search engines can
read it.
Then the client takes over. Vue hydrates the server HTML: it walks the existing DOM, attaches event listeners, and makes the page interactive. It does not rebuild the DOM โ it adopts it.
Hydration only works if the HTML the client would render matches the HTML the server sent. When the two disagree, Vue reports a hydration mismatch and patches the difference, which is slower and can drop state.
Mismatches come from output that differs between the two runs. Date.now(),
Math.random(), or reading localStorage during render produce one value on the
server and another on the client:
<template>
<p>{{ new Date().toLocaleTimeString() }}</p>
</template>
Keep render output deterministic. Move browser-only work into onMounted, which
runs after hydration, or wrap the subtree in <ClientOnly> so the server skips
it.
Server rendering gives you fast first paint and indexable HTML; hydration is the handover that makes that HTML live.
You are about to answer a short quiz on server rendering and hydration.