Incremental Hydration with @defer
Hydrate parts of the page on demand.
Incremental Hydration with @defer is a free Angular Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Angular Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
The Cost Of Full Hydration
Full hydration boots every component up front. Incremental hydration instead hydrates parts of the page on demand, deferring JavaScript for sections until they are needed.
Built On defer
Incremental hydration uses the @defer block with the special hydrate triggers. The server still renders the content, but the client hydrates it only when a trigger fires.
@defer (hydrate on viewport) {
<app-comments />
}Enabling It
Opt in with withIncrementalHydration() in the hydration provider. This unlocks the hydrate triggers in templates.
import { provideClientHydration, withIncrementalHydration } from '@angular/platform-browser';
providers: [provideClientHydration(withIncrementalHydration())]hydrate on viewport
The most common trigger hydrates a block when it scrolls into view. Below-the-fold content stays dormant, saving JavaScript work until the user reaches it.
@defer (hydrate on viewport) {
<app-related-products />
}hydrate on interaction
Hydrate when the user interacts (click, keydown) with the block. Perfect for widgets that are visible but rarely used, like an expandable panel.
@defer (hydrate on interaction) {
<app-share-menu />
}hydrate on idle and timer
Use hydrate on idle to hydrate when the browser is free, or hydrate on timer(2s) to hydrate after a delay. Good for non-critical regions.
@defer (hydrate on idle) {
<app-newsletter />
}hydrate never
hydrate never keeps the server-rendered HTML static: it displays but never ships JS for that block. Ideal for purely presentational, non-interactive content.
@defer (hydrate never) {
<app-footer-links />
}Difference From Plain defer
A normal @defer in a CSR context shows a placeholder until loaded. With incremental hydration the content is already server-rendered and visible; the trigger only controls when interactivity (hydration) kicks in.
Combining Triggers
You can combine triggers so a block hydrates on whichever happens first, balancing readiness with resource savings.
@defer (hydrate on viewport; hydrate on interaction) {
<app-map />
}Smaller Initial JS
By deferring hydration of heavy or below-the-fold components, the initial JavaScript needed for interactivity shrinks, improving time-to-interactive and INP on the critical path.
Choosing Triggers Wisely
Hydrate above-the-fold interactive elements eagerly or on idle; defer below-the-fold and rarely-used widgets to viewport or interaction. Measure to confirm the wins.
Quick Check
Check your incremental hydration knowledge.
Recap
You used @defer (hydrate ...) with withIncrementalHydration() to hydrate on viewport, interaction, idle, timer, or never. This shrinks initial JS and improves interactivity by deferring hydration of below-the-fold and rarely-used blocks.
Frequently asked questions
Is the “Incremental Hydration with @defer” lesson free?
Yes — the full text of “Incremental Hydration with @defer” is free to read here on the web, and the Angular Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Angular Academy course, upgrade to CoddyKit PRO.
What will I learn in “Incremental Hydration with @defer”?
Hydrate parts of the page on demand. 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; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Incremental Hydration with @defer” 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
- What Is Hydration
- Enabling Full Hydration
- Incremental Hydration with @defer
- Measuring Core Web Vitals