React Server Components Architecture

Server
📄 Layout.tsx
🗄️ UserList.tsx
📊 Dashboard.tsx
Client
🖱️ SearchBar.tsx
🔔 Notifications.tsx
📝 CommentForm.tsx
RSC Payload → Streamed to Client
0 KB
Server component JS sent to client
Direct
DB / filesystem access on server
Stream
Progressive HTML rendering
Hybrid
Mix server & client in one tree

"use client" marks the boundary — everything above is server by default

// app/page.tsx  (Server Component — no directive needed)
import { db } from '@/lib/db';
import { SearchBar } from './SearchBar';

export default async function Page() {
  const users = await db.users.findMany(); // direct DB access

  return (
    <main>
      <SearchBar />  {/* client component */}
      {users.map(u => <p key={u.id}>{u.name}</p>)}
    </main>
  );
}

// app/SearchBar.tsx
'use client';  // ← marks the client boundary

import { useState } from 'react';

export function SearchBar() {
  const [query, setQuery] = useState('');
  return <input value={query} onChange={e => setQuery(e.target.value)} />;
}