When to Hydrate vs Keep Static in Astro
📖 Scenario: You are building a simple product showcase page using Astro. Some parts of the page need to be interactive, like a button that shows an alert when clicked. Other parts are static and do not need any JavaScript on the client side.
🎯 Goal: Learn how to decide when to hydrate components for interactivity and when to keep components static in Astro. You will create a static product list and an interactive button that only hydrates when needed.
📋 What You'll Learn
Create a static product list component in Astro
Create an interactive button component that shows an alert on click
Use Astro's hydration directives to hydrate the button only on client
Keep the product list static with no client-side JavaScript
💡 Why This Matters
🌍 Real World
Websites often have parts that are static and parts that need interactivity. Knowing when to hydrate components helps build fast, efficient sites.
💼 Career
Front-end developers use hydration strategies to optimize performance and user experience in modern frameworks like Astro.
Progress0 / 4 steps