Passing Fetched Data to Client Components
What you'll learn: How to fetch data in Server Components and seamlessly pass the results to interactive Client Components as props.
The Bridge Between Server and Client
Server Components can fetch data directly from databases, APIs, or the filesystem—then pass that data to Client Components through props. This is the primary pattern for combining server-side data access with client-side interactivity.
Think of it like a restaurant kitchen (Server Component) preparing a meal and handing it to the waiter (props) who delivers it to the customer's table (Client Component). The customer doesn't see the cooking process—just the finished dish.
How It Works
Server Components execute on the server, fetch whatever data they need using async/await, then pass serializable results as props to Client Components. The Client Component receives fully-resolved data—no loading states needed:
// app/UserProfile.tsx (Server Component - default)
async function UserProfile({ userId }: { userId: string }) {
const user = await db.user.findUnique({ where: { id: userId } });
// Pass fetched data to Client Component
return <InteractiveProfile user={user} />;
}
// app/InteractiveProfile.tsx (Client Component)
'use client';
export function InteractiveProfile({ user }: { user: User }) {
const [isEditing, setIsEditing] = useState(false);
// Receives fully-loaded data as props
return (
<div>
<h1>{user.name}</h1>
<button onClick={() => setIsEditing(true)}>Edit</button>
</div>
);
}
The user object must be serializable (plain objects, strings, numbers, arrays—no functions or class instances). The Server Component handles the async complexity; the Client Component just receives clean data.
Key Takeaway: Server Components fetch data and pass serializable results as props to Client Components, eliminating the need for loading states in client code while keeping interactive features intact.