Part 06 / Topic 2 of 6
Serializable props across the boundary
A Server Component and a Client Component never run in the same process at the same time — the Server Component's output has to be turned into data (the "RSC Payload" the installed package's own docs describe) before a Client Component on the other side can read it as props. AddToCartCounter only ever receives two strings and a number:
<AddToCartCounter productId={product.id} name={product.name} price={product.price} />
and that is deliberate, not incidental — every one of those three values survives the trip because it is a plain, JSON-shaped value. Confirmed for real against the running harness, the quantity stepper and subtotal both work from a clean page load:
$ curl -s http://localhost:PORT/store/quick-add/p1 | grep -o '<main[^>]*>.*</main>'
<main style="font-family:system-ui;padding:2rem;max-width:560px"><h1>Jaipur Blue Pottery Vase</h1><p>₹<!-- -->1,299</p><div style="margin-top:1rem"><div style="display:flex;align-items:center;gap:0.5rem"><button type="button" aria-label="Decrease quantity">−</button><span data-testid="quantity">1</span><button type="button" aria-label="Increase quantity">+</button><button type="button">Add to cart</button></div><p>Subtotal: ₹<!-- -->1,299</p></div><div style="border:1px solid #ddd;border-radius:4px;padding:0.75rem 1rem;margin-top:1rem"><button type="button" aria-expanded="false">Show<!-- --> <!-- -->product details</button></div><p><a href="/store">Back to Apna Bazaar</a></p></main>
Clicking the +/− buttons and "Add to cart" afterward is a real browser interaction this harness's curl/next build convention cannot exercise — the same limitation Part 3 named for useRouter().push and template.tsx's remount. What is independently verified here is everything up to that point: the component received its props, rendered the starting state correctly, and the installed package's own docs state the behavior directly — "Props passed to Client Components need to be serializable by React."
🔍 Going deeper — "serializable" is more generous than plain JSON: It is tempting to read "serializable" as "JSON-safe: strings, numbers, booleans, plain objects and arrays, nothing else." Tested directly against this harness, that's an oversimplification: passing a real
Dateobject as a prop from a Server Component to a Client Component works, and the value really does arrive as aDateinstance on the other side, not a string that merely looks like one:// Server Component <DateShow when={new Date("2026-01-01T00:00:00.000Z")} /> // Client Component "use client"; export default function DateShow({ when }: { when: Date }) { return <p>{when instanceof Date ? "real Date on the client" : "not a Date"}: {when.toISOString()}</p>; }$ npm run build && grep -o '<p>[^<]*</p>' .next/server/app/store/ex-date.html <p>real Date on the client: 2026-01-01T00:00:00.000Z</p>React's own serialization format for this boundary (the same mechanism behind the "RSC Payload") supports more than bare JSON — this course verified
Datespecifically rather than asserting the full list from memory; treat "serializable by React" (the docs' own phrase, linked above) as the rule, and test anything unusual the same way before relying on it.The other edge of the same rule, also verified directly: a class instance does not cross, even one holding nothing but plain numbers and strings. Passing
new Money(1299, "INR")(a two-field class) as a prop fails the build with a message that names the real rule precisely:$ npm run build ... Error: Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported. {money: {amount: 1299, currency: "INR"}} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Passing
{ amount: 1299, currency: "INR" }— the identical data, as a plain object literal instead of a class instance — builds and renders cleanly. "Serializable" means plain data shapes (objects, arrays, strings, numbers, booleans, and a short list of built-ins React special-cases,Dateamong them) — never an instance of a class you defined, no matter how simple its fields are.
Full file: examples/01-add-to-cart-counter.tsx.
Done here? The practice set for Part 6 — including the solutions — is on the part page.