SlideShare a Scribd company logo
5
Most read
9
Most read
11
Most read
Angular Hydration
Alka Vats & Anuj Tomar
Lack of etiquette and manners is a huge turn off.
KnolX Etiquettes
 Punctuality
Join the session 5 minutes prior to the session start time. We start on
time and conclude on time!
 Feedback
Make sure to submit a constructive feedback for all sessions as it is very
helpful for the presenter.
 Silent Mode
Keep your mobile devices in silent mode, feel free to move out of session
in case you need to attend an urgent call.
 Avoid Disturbance
Avoid unwanted chit chat during the session.
1. What is Angular Hydration?
2. Why is Hydration Important?
3. How Angular Hydration Works
4. Implementation
5. Constraints of Hydration
6. Demo
01
What is Angular Hydration?
 Angular Hydration is the process where a server-rendered HTML page is transformed into a fully
interactive Angular application on the client side.
 The server sends a fully-rendered HTML page to the client. Angular then takes over by attaching
event listeners and making the page interactive, effectively transforming static content into a
dynamic application.
02
Why is Hydration Important?
 Performance Benefits:
 Faster Initial Load: Server-side rendering provides a fully-rendered HTML page to the user, reducing
the time to first paint (TTFP).
 SEO Improvements: Search engines can crawl and index the server-rendered content, improving
search engine optimization (SEO).
 Improved User Experience: Users see the content faster, leading to better engagement and lower
bounce rates.
 Challenges without Hydration:
 Slow Initial Load: Applications relying solely on client-side rendering can have slower initial load times.
 SEO Limitations: Client-side rendered content can be less effective for SEO, as search engines might
not index JavaScript-heavy pages well.
 User Perception: Delayed content visibility can lead to higher bounce rates and lower user satisfaction.
03
How Angular Hydration Works
 Process Overview:
 Server-Side Rendering (SSR): The server generates the initial HTML of the Angular application.
 Hydration: The client-side Angular framework bootstraps and rehydrates the server-rendered HTML,
attaching event listeners and making it interactive.
 Steps:
 Initial Server Render: The Angular application is rendered on the server and sent to the client as
HTML.
 Sending HTML to Client: The client receives a fully-rendered HTML page.
 Angular Bootstrapping: Angular bootstraps the application on the client side, making the static HTML
interactive by attaching event listeners and other Angular functionalities.
 Rehydration Process: Angular verifies the server-rendered content, binds it to the client-side Angular
components, and activates event listeners.
04
Implementation
 Enable Server-side rendering
 To create a new project with SSR, run:
$ ng new –ssr
 To add SSR to an existing project, use the Angular CLI ng add command.
$ ng add @angular/ssr
 If you have a custom setup and didn't use Angular CLI to enable SSR, you can enable hydration manually by
visiting your main application component or module and
importing provideClientHydration from @angular/platform-browser. You'll then add that provider to your
app's bootstrapping providers list.
import {
bootstrapApplication,
provideClientHydration,
} from '@angular/platform-browser';
…
bootstrapApplication(AppComponent, {
providers: [provideClientHydration()]
});
 Alternatively, if you are using NgModules, you would add provideClientHydration to your root app module's
provider list.
import {provideClientHydration} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
@NgModule({
declarations: [AppComponent],
exports: [AppComponent],
bootstrap: [AppComponent],
providers: [provideClientHydration()],
})
export class AppModule {}
05
Constraints of Hydration
 Direct DOM Manipulation
 If you have components that manipulate the DOM using native DOM APIs, innerHTML or outerHTML,
the hydration process will encounter errors.
 Valid HTML Structure
 There are a few cases where if you have a component template that does not have a valid HTML
structure, this could result in a DOM mismatch error during hydration.
 For example, here are some of the most common cases of this issue.
 < table > without a < tbody >
 < div > inside a < p >
 < a > inside an < h1 >
 < a > inside another < a >
 Preserve Whitespaces Configuration
 When using the hydration feature, we recommend using the default false setting for
preserveWhitespaces. If this setting is not in your tsconfig, the value will be false, and no changes are
required. If you choose to enable preserving whitespaces by adding preserveWhitespaces: true to your
tsconfig, you may encounter issues with hydration.
 Support for i18N
 Angular v17 still doesn’t support internationalization with hydration, but support is in progress.
Components using i18N blocks will have hydration skipped.
 Third-Party Libraries with DOM Manipulation
 Several third-party libraries depend on DOM manipulation to be able to render. D3 charts are a prime
example. These libraries worked without hydration but may cause DOM mismatch errors when hydration
is enabled. Use ngSkipHydration on the component using such libraries to bypass hydration.
06
Angular Hydration Presentation (FrontEnd)

More Related Content

PPTX
Java 17 features and implementation.pptx
PPTX
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
PPTX
Self-Healing Test Automation Framework - Healenium
PPTX
Kanban Metrics Presentation (Project Management)
PPTX
Chaos Mesh Introducing Chaos in Kubernetes
PPTX
GraalVM - A Step Ahead of JVM Presentation
PPTX
Nomad by HashiCorp Presentation (DevOps)
PPTX
Nomad by HashiCorp Presentation (DevOps)
Java 17 features and implementation.pptx
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Self-Healing Test Automation Framework - Healenium
Kanban Metrics Presentation (Project Management)
Chaos Mesh Introducing Chaos in Kubernetes
GraalVM - A Step Ahead of JVM Presentation
Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)

More from Knoldus Inc. (20)

PPTX
DAPR - Distributed Application Runtime Presentation
PPTX
Introduction to Azure Virtual WAN Presentation
PPTX
Introduction to Argo Rollouts Presentation
PPTX
Intro to Azure Container App Presentation
PPTX
Insights Unveiled Test Reporting and Observability Excellence
PPTX
Introduction to Splunk Presentation (DevOps)
PPTX
Code Camp - Data Profiling and Quality Analysis Framework
PPTX
AWS: Messaging Services in AWS Presentation
PPTX
Amazon Cognito: A Primer on Authentication and Authorization
PPTX
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
PPTX
Managing State & HTTP Requests In Ionic.
PPTX
Facilitation Skills - When to Use and Why.pptx
PPTX
Performance Testing at Scale Techniques for High-Volume Services
PPTX
Snowflake and its features (Presentation)
PPTX
Terratest - Automation testing of infrastructure
PPTX
Getting Started with Apache Spark (Scala)
PPTX
Secure practices with dot net services.pptx
PPTX
Distributed Cache with dot microservices
PPTX
Introduction to gRPC Presentation (Java)
PPTX
Using InfluxDB for real-time monitoring in Jmeter
DAPR - Distributed Application Runtime Presentation
Introduction to Azure Virtual WAN Presentation
Introduction to Argo Rollouts Presentation
Intro to Azure Container App Presentation
Insights Unveiled Test Reporting and Observability Excellence
Introduction to Splunk Presentation (DevOps)
Code Camp - Data Profiling and Quality Analysis Framework
AWS: Messaging Services in AWS Presentation
Amazon Cognito: A Primer on Authentication and Authorization
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
Managing State & HTTP Requests In Ionic.
Facilitation Skills - When to Use and Why.pptx
Performance Testing at Scale Techniques for High-Volume Services
Snowflake and its features (Presentation)
Terratest - Automation testing of infrastructure
Getting Started with Apache Spark (Scala)
Secure practices with dot net services.pptx
Distributed Cache with dot microservices
Introduction to gRPC Presentation (Java)
Using InfluxDB for real-time monitoring in Jmeter
Ad

Recently uploaded (20)

PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Machine Learning_overview_presentation.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Encapsulation_ Review paper, used for researhc scholars
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Electronic commerce courselecture one. Pdf
PDF
Encapsulation theory and applications.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Spectroscopy.pptx food analysis technology
Digital-Transformation-Roadmap-for-Companies.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
gpt5_lecture_notes_comprehensive_20250812015547.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
MIND Revenue Release Quarter 2 2025 Press Release
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Machine learning based COVID-19 study performance prediction
Machine Learning_overview_presentation.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Encapsulation_ Review paper, used for researhc scholars
“AI and Expert System Decision Support & Business Intelligence Systems”
Building Integrated photovoltaic BIPV_UPV.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Electronic commerce courselecture one. Pdf
Encapsulation theory and applications.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
sap open course for s4hana steps from ECC to s4
Assigned Numbers - 2025 - Bluetooth® Document
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Spectroscopy.pptx food analysis technology
Ad

Angular Hydration Presentation (FrontEnd)

  • 2. Lack of etiquette and manners is a huge turn off. KnolX Etiquettes  Punctuality Join the session 5 minutes prior to the session start time. We start on time and conclude on time!  Feedback Make sure to submit a constructive feedback for all sessions as it is very helpful for the presenter.  Silent Mode Keep your mobile devices in silent mode, feel free to move out of session in case you need to attend an urgent call.  Avoid Disturbance Avoid unwanted chit chat during the session.
  • 3. 1. What is Angular Hydration? 2. Why is Hydration Important? 3. How Angular Hydration Works 4. Implementation 5. Constraints of Hydration 6. Demo
  • 4. 01
  • 5. What is Angular Hydration?  Angular Hydration is the process where a server-rendered HTML page is transformed into a fully interactive Angular application on the client side.  The server sends a fully-rendered HTML page to the client. Angular then takes over by attaching event listeners and making the page interactive, effectively transforming static content into a dynamic application.
  • 6. 02
  • 7. Why is Hydration Important?  Performance Benefits:  Faster Initial Load: Server-side rendering provides a fully-rendered HTML page to the user, reducing the time to first paint (TTFP).  SEO Improvements: Search engines can crawl and index the server-rendered content, improving search engine optimization (SEO).  Improved User Experience: Users see the content faster, leading to better engagement and lower bounce rates.  Challenges without Hydration:  Slow Initial Load: Applications relying solely on client-side rendering can have slower initial load times.  SEO Limitations: Client-side rendered content can be less effective for SEO, as search engines might not index JavaScript-heavy pages well.  User Perception: Delayed content visibility can lead to higher bounce rates and lower user satisfaction.
  • 8. 03
  • 9. How Angular Hydration Works  Process Overview:  Server-Side Rendering (SSR): The server generates the initial HTML of the Angular application.  Hydration: The client-side Angular framework bootstraps and rehydrates the server-rendered HTML, attaching event listeners and making it interactive.  Steps:  Initial Server Render: The Angular application is rendered on the server and sent to the client as HTML.  Sending HTML to Client: The client receives a fully-rendered HTML page.  Angular Bootstrapping: Angular bootstraps the application on the client side, making the static HTML interactive by attaching event listeners and other Angular functionalities.  Rehydration Process: Angular verifies the server-rendered content, binds it to the client-side Angular components, and activates event listeners.
  • 10. 04
  • 11. Implementation  Enable Server-side rendering  To create a new project with SSR, run: $ ng new –ssr  To add SSR to an existing project, use the Angular CLI ng add command. $ ng add @angular/ssr
  • 12.  If you have a custom setup and didn't use Angular CLI to enable SSR, you can enable hydration manually by visiting your main application component or module and importing provideClientHydration from @angular/platform-browser. You'll then add that provider to your app's bootstrapping providers list. import { bootstrapApplication, provideClientHydration, } from '@angular/platform-browser'; … bootstrapApplication(AppComponent, { providers: [provideClientHydration()] });
  • 13.  Alternatively, if you are using NgModules, you would add provideClientHydration to your root app module's provider list. import {provideClientHydration} from '@angular/platform-browser'; import {NgModule} from '@angular/core'; @NgModule({ declarations: [AppComponent], exports: [AppComponent], bootstrap: [AppComponent], providers: [provideClientHydration()], }) export class AppModule {}
  • 14. 05
  • 15. Constraints of Hydration  Direct DOM Manipulation  If you have components that manipulate the DOM using native DOM APIs, innerHTML or outerHTML, the hydration process will encounter errors.  Valid HTML Structure  There are a few cases where if you have a component template that does not have a valid HTML structure, this could result in a DOM mismatch error during hydration.  For example, here are some of the most common cases of this issue.  < table > without a < tbody >  < div > inside a < p >  < a > inside an < h1 >  < a > inside another < a >
  • 16.  Preserve Whitespaces Configuration  When using the hydration feature, we recommend using the default false setting for preserveWhitespaces. If this setting is not in your tsconfig, the value will be false, and no changes are required. If you choose to enable preserving whitespaces by adding preserveWhitespaces: true to your tsconfig, you may encounter issues with hydration.  Support for i18N  Angular v17 still doesn’t support internationalization with hydration, but support is in progress. Components using i18N blocks will have hydration skipped.  Third-Party Libraries with DOM Manipulation  Several third-party libraries depend on DOM manipulation to be able to render. D3 charts are a prime example. These libraries worked without hydration but may cause DOM mismatch errors when hydration is enabled. Use ngSkipHydration on the component using such libraries to bypass hydration.
  • 17. 06