The error useState can only be used in Client Components, or its sibling Event handlers cannot be passed to Client Component props, shows up early for almost every developer moving from the Pages Router to the App Router. The instinctive reaction is to slap 'use client' on every file that complains, until the whole app is back to classic client-side rendering, which defeats the entire point of Server Components. Understanding the real boundary between the two models avoids that reflex and lets you design component trees that actually take advantage of server rendering.

The mental model: two runtimes, not two flavors of syntax

In the App Router, every component is a Server Component by default. A Server Component runs only on the server (or at build time for static generation), never ships into the JavaScript bundle sent to the browser, and can therefore do things a client component can't do directly: await a database query or an API call carrying secrets, read the filesystem, import heavy packages without bloating the client bundle.

// app/products/[id]/page.tsx - Server Component by default, no directive needed
import { db } from '@/lib/db';

export default async function ProductPage({ params }: { params: { id: string } }) {
  const product = await db.product.findUnique({ where: { id: params.id } });

  if (!product) {
    return <p>Product not found.</p>;
  }

  return (
    <div>
      <h1>{product.name}</h1>
      <p>{product.description}</p>
      <AddToCartButton productId={product.id} />
    </div>
  );
}

A Client Component, marked with the 'use client' directive at the top of the file, runs in the browser (after an initial server render produces the first HTML) and can therefore use useState, useEffect, event listeners, and any browser API (localStorage, window, geolocation).

// app/products/[id]/AddToCartButton.tsx
'use client';

import { useState } from 'react';

export function AddToCartButton({ productId }: { productId: string }) {
  const [isAdding, setIsAdding] = useState(false);

  async function handleClick() {
    setIsAdding(true);
    await fetch('/api/cart', { method: 'POST', body: JSON.stringify({ productId }) });
    setIsAdding(false);
  }

  return (
    <button onClick={handleClick} disabled={isAdding}>
      {isAdding ? 'Adding...' : 'Add to cart'}
    </button>
  );
}

This isn't a stylistic choice: useState literally cannot exist in a component that never runs in the browser, since client-side state implies a render-and-re-render cycle that doesn't mean anything on the server.

The composition rule that avoids 90% of the errors

'use client' marks the point from which an entire subtree becomes client-rendered, but it doesn't propagate upward to parents. In other words, a Server Component can import and render a Client Component (the way ProductPage renders AddToCartButton above), but a Client Component cannot import a Server Component to execute it in its own context - because by the time React runs that client code in the browser, there's no server left available to produce that Server Component's output.

The typical mistake comes from the reversed intuition:

// Wrong: CartPanel is 'use client' and tries to import a Server Component
'use client';

import { RecommendedProducts } from './RecommendedProducts'; // Server Component doing a DB fetch

export function CartPanel() {
  const [isOpen, setIsOpen] = useState(false);
  return (
    <div className={isOpen ? 'open' : 'closed'}>
      <RecommendedProducts /> {/* won't behave as expected */}
    </div>
  );
}

Next.js won't necessarily throw an explicit error here depending on the case, but RecommendedProducts ends up treated as an ordinary client component (losing its server-only capabilities, or the import simply fails if the file uses server-only APIs like fs or a Prisma client). The fix is to invert the relationship: pass the Server Component down as children or as a prop from a server parent.

// Right: the parent (a Server Component) composes both
// app/cart/page.tsx
import { CartPanel } from './CartPanel';
import { RecommendedProducts } from './RecommendedProducts';

export default function CartPage() {
  return (
    <CartPanel>
      <RecommendedProducts />
    </CartPanel>
  );
}
// CartPanel.tsx
'use client';

export function CartPanel({ children }: { children: React.ReactNode }) {
  const [isOpen, setIsOpen] = useState(false);
  return <div className={isOpen ? 'open' : 'closed'}>{children}</div>;
}

children here is a "hole" in the client tree, already rendered to HTML on the server, that the Client Component simply displays without ever executing its code. This is the central pattern for keeping a Server Component deep inside an otherwise interactive tree.

Where to draw the line on a real page

The question to ask per component isn't "does this component display data" but "does this component need browser interactivity (state, effects, event handlers, browser APIs) or a React context (useContext) fed by a client Provider?" If not, it stays a Server Component by default, even if it receives complex props.

A common pattern on a dashboard-style page:

// Server Component: fetches data, no interactivity
export default async function DashboardPage() {
  const stats = await getStats();
  return (
    <section>
      <StatsSummary stats={stats} />      {/* Server Component: pure display */}
      <StatsChart data={stats.timeline} /> {/* Client Component: interactive charting library */}
    </section>
  );
}

StatsSummary has no reason to be a client component even though it displays dynamic numbers, since it just renders JSX from already-resolved props. StatsChart probably does need 'use client' because the charting library (Recharts, Chart.js) manipulates the DOM, listens for hover events, and makes no sense running on the server.

Edge cases that trip up even experienced developers

  • Unmarked third-party hooks: a library that exports a React hook without a 'use client' directive in its own code breaks when imported into a Server Component. The fix is to wrap that import inside a small, dedicated Client Component.
  • Context.Provider: createContext/useContext requires the Provider itself to be a Client Component. The common pattern is a single client Providers.tsx, mounted once near the top of the tree in layout.tsx, that wraps children (a Server Component) without forcing everything else to be client-side.
  • Environment variables: a variable without the NEXT_PUBLIC_ prefix read inside a Server Component is never exposed to the client, which is correct for secrets, but breaks silently if you expect to read it again after hydration.
  • Server Actions: a server function invoked from a client form ('use server' inside the function, called via action={myServerAction}) remains the idiomatic way to do mutations without a dedicated API route, and is usually preferable to a manual fetch against a route.ts handler for simple mutations.

Streaming with Suspense across the boundary

The Server/Client split also interacts directly with streaming. Wrapping a slow Server Component in <Suspense> lets Next.js send the surrounding page HTML immediately and stream in the slow part once its data is ready, instead of blocking the entire response on the slowest query:

// app/dashboard/page.tsx
import { Suspense } from 'react';

export default function DashboardPage() {
  return (
    <section>
      <h1>Dashboard</h1>
      <Suspense fallback={<StatsSkeleton />}>
        <SlowRevenueWidget />
      </Suspense>
    </section>
  );
}

async function SlowRevenueWidget() {
  const revenue = await computeRevenueAcrossRegions(); // slow aggregate query
  return <RevenueTable data={revenue} />;
}

This only works because SlowRevenueWidget is a Server Component: React can suspend its render on the server, flush the fallback first, and patch in the real markup over the same connection once the await resolves. A Client Component wrapped the same way behaves differently, since the suspension there typically relates to a lazily loaded client bundle or a client-side data fetch, not a server-side await. Mixing both in the same tree is common and useful, for instance a static page shell (server), with a Suspense boundary around a Server Component doing a slow read, and a Client Component further down for an interactive filter, each suspending for its own reason.

Testing the boundary deliberately

Because the error messages for a misplaced 'use client' boundary are not always explicit, it's worth deliberately testing the boundary rather than discovering it in production. A quick sanity check during review: pick any file without the directive, and ask whether removing every hook and event handler from it would change its behavior. If the answer is no, it has no business being a Client Component even if a sibling file happens to be one. Codebases that drift toward "mark it client just in case it complains" tend to end up with most of the page tree client-rendered within a few months, quietly losing the server-rendering benefits the App Router was adopted for in the first place.

When the Server/Client split isn't the whole answer

Splitting Server and Client correctly answers "where does this code run," not "how fresh is this data." A Server Component doing a fetch without explicit cache configuration can serve stale data for the duration of Next.js's default caching behavior, which often surprises people during QA. That requires reasoning separately about cache: 'no-store', revalidation tags (revalidateTag), or incremental regeneration (revalidate), all of which are decisions independent of the Server/Client choice.

Takeaway

Server Component is the default; Client Component is the exception reserved for what genuinely needs the browser. The composition rule to remember is that a client tree can receive an already-rendered Server Component via children/props, but can never import it to execute it itself. Push 'use client' as far down the tree as possible, component by component, to keep as much code on the server and the client bundle as small as it can be.