Course contentsShow
← React
Lesson 1582 of 2,39639. Server Components in PracticeFree lesson

Async Components Cannot Use Hooks

Async server components cannot call useState, useEffect, or any hooks; they run once on the server.

Async Components Cannot Use Hooks

You'll learn why async server components can't use React hooks and what this means for your component architecture.

When you make a server component async, it fundamentally changes how and when that component runs—and this creates an incompatibility with React's hook system.

Why Hooks Don't Work in Async Components

Hooks like useState, useEffect, and useContext were designed for reactive, client-side components that re-render in response to state changes. They rely on React's render cycle and component lifecycle.

Async server components, however, run exactly once on the server during the initial render. They're not reactive—they execute, await their data, and return JSX. There's no "next render" for them to participate in, no client-side lifecycle to hook into.

Think of it like this: hooks are like having a conversation where you can respond and react. An async server component is like sending a letter—you write it once, send it, and that's it. You can't have an ongoing conversation through a letter.

The Mental Model Shift

// ❌ This will error - async components can't use hooks
async function UserProfile({ id }) {
  const [count, setCount] = useState(0); // Error!
  const user = await fetchUser(id);
  return <div>{user.name}</div>;
}

// ✅ Async for data, no hooks
async function UserProfile({ id }) {
  const user = await fetchUser(id);
  return <div>{user.name}</div>;
}

If you need interactivity or state, that logic must live in a client component (marked with 'use client'). Server components handle the data-fetching; client components handle the interaction.

Key Takeaway: Async server components execute once on the server and cannot use any React hooks—they're for data fetching and rendering, not reactivity or state management.