Using the client:load Directive in Astro
📖 Scenario: You are building a simple Astro website that shows a welcome message and a button. You want the button to show an alert when clicked, but only after the page has fully loaded in the browser.
🎯 Goal: Create an Astro component that uses the client:load directive to load a small interactive script only after the page loads, so the alert button works correctly.
📋 What You'll Learn
Create an Astro component with a heading and a button
Add a script that shows an alert when the button is clicked
Use the
client:load directive to load the script only after the page loads💡 Why This Matters
🌍 Real World
Websites often need interactive parts that should only run after the page loads to improve speed and user experience.
💼 Career
Knowing how to use client directives in Astro helps build fast, modern websites with optimized loading behavior.
Progress0 / 4 steps