CodeZettaInterview Hub

Next.js · Server Components · Junior · Debugging

Why can't you use useState or onClick in a Server Component?

Short Interview Answer

Those require client runtime and interactivity; Server Components have no client hook runtime.

Detailed Explanation

Mark interactive leaves with `'use client'`. Keep parents as Server Components when possible so only interactive islands hydrate. Passing event handlers as props from server to client is not allowed — pass data and define handlers in client code.

Common Mistake

Sprinkling 'use client' at the root and losing RSC benefits.

Did you know this answer?