When to Use Which

Decision Table

You need to...ServerClient
Fetch data, read the databaseYesPossible, but slower
Use API keys or secretsYesNever
Keep large libraries out of the bundle (markdown, date libs)YesNo
onClick, onChange, forms with live validationNoYes
useState, useEffect, useReducer, ContextNoYes
Browser APIs: localStorage, window, geolocationNoYes

Common Mistake

Example

Using a hook in a Server Component fails at build time:

npm run build

Example output

Error:   x You're importing a component that needs `useState`. This React Hook only works
  | in a Client Component. To fix, mark the file (or its parent) with the `"use client"` directive.
   ,-[app/products/page.tsx:1:1]
 1 | import { useState } from 'react';

Tip: Start with Server Components everywhere. Add 'use client' only to the small pieces that need interactivity.