Angular Academy · Lesson

Enabling Full Hydration

Turn on hydration to avoid re-rendering.

Lesson 2 of 413 steps

Enabling Full Hydration is a free Angular Academy lesson on CoddyKit. This is lesson 2 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the Angular Academy learning path, and your progress syncs across the web and the CoddyKit app. The Angular Academy course includes 4 lessons in total.

Turning On Hydration

Full hydration is enabled by adding provideClientHydration() to your application providers. The ng add @angular/ssr schematic adds it for you.

import { provideClientHydration } from '@angular/platform-browser';

export const appConfig = {
  providers: [provideClientHydration()]
};

Where It Goes

It belongs in the browser appConfig providers, the same config used to bootstrap the client. The server config merges on top with provideServerRendering().

What Full Means

Full (eager) hydration hydrates the entire component tree as soon as the JavaScript loads and Angular boots. Every component becomes interactive at once.

Event Replay

Enable withEventReplay() so user interactions that happen before hydration completes are captured and replayed afterward, preventing lost clicks on slow devices.

import { provideClientHydration, withEventReplay } from '@angular/platform-browser';

providers: [provideClientHydration(withEventReplay())]

HTTP Transfer Cache

With hydration on, HttpClient GET responses from the server are cached into TransferState by default, so the client does not refetch the same data after boot.

provideClientHydration(withHttpTransferCacheOptions({ filter: r => r.method === 'GET' }))

Verifying Hydration

Open the console in dev mode. Angular logs hydration stats (components hydrated, nodes reused). No mismatch warnings means hydration succeeded cleanly.

// Angular hydrated 24 component(s) and 187 node(s)

Fixing Mismatches

If you see NG0500 mismatch errors, find non-deterministic templates or manual DOM edits. Make markup deterministic so server and client outputs agree.

Guard Browser APIs

Code that touches window or localStorage during initial render can change markup between server and client. Guard with isPlatformBrowser or run it after view init.

if (isPlatformBrowser(this.platformId)) {
  this.width = window.innerWidth;
}

Full Hydration Tradeoff

Full hydration is simple but downloads and executes all component JavaScript up front. For large apps this can delay interactivity, which incremental hydration addresses.

i18n And Hydration

Hydration works with Angular i18n, but ensure translated content is deterministic. Mismatched locales between server and client cause hydration errors.

Production Check

Before shipping, build for production, serve the SSR output, and confirm in the network and console that hydration runs without mismatches and the transfer cache prevents double fetches.

Quick Check

Check your full hydration knowledge.

Recap

You enabled full hydration with provideClientHydration(), added withEventReplay() for pre-hydration clicks, relied on the HTTP transfer cache, guarded browser APIs, and verified clean hydration. Full hydration is simple but loads all JS up front.

Free to start

Learn HTML with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
38
Lessons
144

Frequently Asked Questions

Is the “Enabling Full Hydration” lesson free?

Yes — any 3 lessons of the Angular Academy learning path, including “Enabling Full Hydration”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The Angular Academy course includes 4 lessons in total.

What will I learn in “Enabling Full Hydration”?

Turn on hydration to avoid re-rendering. You practise Angular Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Angular Academy?

No prior experience is required. Angular Academy on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 2 of 4.

How long does the “Enabling Full Hydration” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Angular Academy lesson?

Yes. Every Angular Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. What Is Hydration
  2. Enabling Full Hydration
  3. Incremental Hydration with @defer
  4. Measuring Core Web Vitals
← Back to Angular Academy