Overview - When to hydrate vs keep static
What is it?
In Astro, 'hydration' means making a static web component interactive by adding JavaScript after the page loads. 'Keep static' means the component stays as plain HTML without any JavaScript, so it doesn't change or respond to user actions. Hydration is used when you want parts of your page to be dynamic, while keeping static means faster loading and simpler pages. Choosing between these affects how your website feels and performs.
Why it matters
Hydration lets websites be interactive, like buttons that respond or forms that update without reloading the page. Without hydration, pages would be static and boring, unable to react to user input. But hydration adds JavaScript, which can slow down loading and use more battery on devices. Knowing when to hydrate or keep static helps build websites that are both fast and user-friendly, balancing speed and interactivity.
Where it fits
Before learning this, you should understand basic web components and how Astro builds static sites. After this, you can explore advanced hydration strategies, partial hydration, and client-side state management in Astro. This topic fits in the middle of learning how Astro handles rendering and interactivity.