Consider this Astro component that mixes static and server rendering:
---
const time = new Date().toISOString();
---
Static Time:
{time}
---
// ServerTime.astro
const serverTime = new Date().toISOString();
---
Server Time: {serverTime}
What will the user see when loading this page?
Think about when static props are generated versus server components.
The static time is generated once during build and stays the same. The server time is rendered on each request inside the Astro island, so it updates.
In Astro, how do you mark a component to run only on the server?
Look for the property that enables server-side rendering.
Setting export const ssr = true; marks the component to render only on the server in Astro.
Given this Astro island component:
---
import Counter from '../components/Counter.jsx';
---
The Counter component uses useState and useEffect but the button does not respond to clicks. What is the likely cause?
Check if the Counter component is set up for client-side interactivity.
If Counter is a React component but not marked as a client component (e.g., missing export default function Counter() {} with client directives), it won't hydrate properly.
Analyze this Astro island with a React component:
---
import { useState } from 'react';
---
function Toggle() {
const [on, setOn] = useState(false);
return (
);
}
---
What happens when the user clicks the button?
Consider how React state works inside Astro islands.
The Astro island hydrates the React component on the client, enabling state and event handlers to work normally.
Imagine building a blog with Astro. You want fast page loads and some dynamic user comments. Why choose hybrid rendering (static + server) over fully static or fully server-rendered?
Think about what parts of a blog change often and what parts stay the same.
Hybrid rendering allows static generation for fast loading of mostly fixed content, while server rendering handles dynamic parts like comments, giving a good balance.
