Incremental Hydration with @defer
Hydrate parts of the page on demand.
Incremental Hydration with @defer is a free Angular Academy lesson on CoddyKit. This is lesson 3 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.
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.
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 “Incremental Hydration with @defer” lesson free?
Yes — any 3 lessons of the Angular Academy learning path, including “Incremental Hydration with @defer”, 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 “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, so you can start here or from the beginning and move at your own pace. This is lesson 3 of 4.
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