← All field notes

iLearnNation field notes · 5 min

Where should this React component run?

Choose a server or client boundary by following the data and the interaction, then verify your choice.

Published 2026-10-16 · Original editorial draft

Start with the behavior

Imagine a learning notebook. Its page reads a list of saved notes. One small control lets a learner expand a note. Reading the notes and responding to a click are different responsibilities; placing them in separate components makes the boundary easier to explain.

In the App Router, a page is a Server Component by default. Keep a database read on the server, near its authorization check. Pass the minimum serializable data needed by a small interactive component. A button that holds local state or handles a browser event belongs in a Client Component, declared with the 'use client' directive.

Make one small experiment

Create a server-rendered page with a heading and a nested counter. Put the directive only in the counter file. Give the counter a number as its initial value; clicking the button changes the visible count. The heading and server data read do not need to become interactive to support that button.

Next, deliberately pass a database connection object as a prop. Notice the serialization failure. Replace it with the exact data the counter needs. This is a useful error: it identifies an object crossing a boundary that it cannot cross.

Check what crossed the boundary

  • Does the client receive only data needed for its interface?
  • Are secret keys and database clients confined to server code?
  • Is every protected read authorized on the server?
  • Can the initial page still show useful content before the counter becomes interactive?

A server-rendered page does not automatically make a database read authorized. A hidden button does not protect a server action. Treat each protected operation as its own access boundary.

Debug with a smaller tree

When a hook is rejected in a Server Component, isolate the stateful part rather than adding the client directive to the largest page. If a client bundle includes too much code, inspect the imports under the boundary. Imported children can be pulled into that client graph even when only a small part of the interface handles clicks.

Explain the result in one sentence: the page loads permitted data on the server; the counter manages a browser interaction. If you can explain both halves, you have a boundary you can maintain.

Source and practice

Original example; reviewed against Next.js server and client component guidance on 16 October 2026. Practice the boundary in the course's routing lesson.