The client:load directive tells Astro to load and run a component only after the page has fully loaded in the browser. This helps keep the initial page fast and interactive.
client:load directive in Astro
<ComponentName client:load />
Use it as an attribute on your Astro or framework component.
This directive delays loading the component's JavaScript until after the browser finishes loading the page.
MyWidget only after the page load event.<MyWidget client:load />
Counter component will hydrate and run after the page is fully loaded.<Counter client:load />
This Astro page imports a Counter component and uses client:load to load it only after the page finishes loading. The heading appears immediately, and the counter becomes interactive after load.
--- import Counter from '../components/Counter.jsx'; --- <html lang="en"> <head> <title>Client Load Example</title> </head> <body> <h1>Welcome to Astro</h1> <Counter client:load /> </body> </html>
The client:load directive is great for non-critical interactive parts.
It waits for the full page load event, so it may delay interactivity slightly.
Use it to balance speed and interactivity in your Astro projects.
client:load delays component loading until after the page fully loads.
It helps keep initial page load fast and adds interactivity later.
Use it for widgets or components that don't need to run immediately.