| | |

React Server Components 29 🧬 Cheatsheet

⏱️ Estimated read: 4 min | |

This cheatsheet covers the RSC model as it exists across Next.js, Waku, and custom bundler setups. It is scoped to what you do, not to what exists. The directives, the boundary rules, the security constraints, the testing split, and the performance measurements are the things you reach for mid-build. Each section is a decision, not a directory.


The Three Directives

DirectiveWhereEffect
'use client'Top of fileMarks the client boundary; the module and its imports enter the client bundle
'use server'Top of file or async functionMarks a Server Function; callable from the client as a reference
'use cache'Top of async function or componentCaches the result (Cache Components)

Source:


Server vs Client: the only decision that matters

If the component…DirectiveWhy
Fetches data with awaitnone (Server)Async only works on the server
Uses useState, useEffect, onClick'use client'Hooks and events are browser-only
Reads cookies() or headers()none (Server)Request APIs are server-only
Receives data as props from a Server Component'use client' if interactive, none if notLet the parent fetch
Wraps server content'use client' with childrenThe children stay server-rendered

The Transitivity Rule

The 'use client' boundary is transitive. A module marked with the directive and everything it imports become client code. The size of the client bundle is the size of the subtree beneath each directive, not the number of directives.

PlacementClient bundle
Layout or pageEntire subtree
Section wrapperThe section subtree
Interactive leafThe leaf and its imports
Server ComponentZero (code runs on server)

Server Functions: the security checklist

CheckWhereWhy
Authenticate the sessionInside the functionIt is a public endpoint
Authorize the operationInside the functionThe UI guard is not a security control
Validate inputInside the functionClient arguments are untrusted
Return only needed fieldsThe return statementReturn values are serialized to the client

Never accept a userId from a form field. Derive it from the session.

Source:


Props: the serialization boundary

PatternSafe?Why
<Client user={user} />❌Full object, every field serialized
<Client name={user.name} />✅Only the field the client needs
<Client formatter={fn} />❌Functions are not serializable
<Client action={serverAction} />✅Server Function references are serializable

The rule: pass only the fields the Client Component actually renders. A prop the client does not use is still serialized.

Source:


Secret hygiene

GuardScopeWhat it prevents
import 'server-only'The moduleThe module entering the client graph
experimental_taintUniqueValueThe specific valueThe value crossing the boundary
DTO in the data access layerThe data access layerThe full record leaving the server
NEXT_PUBLIC_ prefixThe variableA server variable reaching the client

import 'server-only' is per-file. A sibling file without it is not protected.

Source:


Third-party wrappers

Library typeWrapper neededPattern
Charts (Recharts)YesRe-export with 'use client'
Animation (Framer Motion)YesAdapter wrapper
UI (MUI interactive)YesRe-export per component
Provider (next-themes)YesWrapper with children
Libraries shipping 'use client'NoImport directly

The wrapper goes at the leaf, not the root. Props must be serializable.


Testing split

Component typeUnit test (Vitest)E2E test (Playwright)
Synchronous Server ComponentYesOptional
Async Server ComponentNoYes
Client ComponentYesOptional
Server ActionNoYes

The async keyword is the boundary. Vitest’s render() receives a Promise, not a component.

Source:


Performance measurements

MetricToolUnit
Client bundlenext experimental-analyzeBytes
RSC payloadcurl -H "RSC: 1" / network ?_rsc=Bytes
Hydration timePerformance trace / Lighthouse TBT/INPMilliseconds
Boundary budgetrsc-contractBytes (estimated)

The RSC payload and the client bundle are different measurements. A smaller bundle does not guarantee a smaller payload.


The four migration patterns

PatternBeforeAfter
Data-fetching componentuseEffect + fetchasync Server Component
Interactive leafClient Component with data fetchingClient Component with props
Provider wrapperClient Component wrapping everythingClient Component with children
Composition slotClient Component importing server contentClient Component with children

The order is leaf-first: data-fetching components, then interactive components, then routes, then mutations.


Framework support reality

FrameworkRSC statusProduction readiness
Next.js App RouterStableProduction-ready
Waku1.0 alphaNot recommended
React Router v7In developmentNot recommended
Custom bundlerPossibleRequires building a framework

RSC cannot run standalone. The framework provides the bundler, the server, and the router.

Source:


The one-line summary

Server by default. Cache explicitly. Auth every action. Narrow every prop.

Server Components are the starting point. 'use cache' is how you opt into caching. Every Server Function re-validates the session because it is a public endpoint. Every prop is narrowed to the fields the client renders because the boundary is serialization, not privacy.


Summary

AreaKey takeaway
Directives'use client', 'use server', 'use cache'
BoundaryTransitive; place it at the leaf
Server FunctionsPublic endpoints; authenticate and authorize inside
PropsSerialized; pass only what the client renders
Secretsserver-only per module; taint values
Third-partyWrapper with 'use client' at the leaf
TestingVitest for sync, Playwright for async
PerformanceBundle and payload are separate measurements
MigrationLeaf-first, four patterns, one route at a time
FrameworkRSC is not standalone; the framework is the runtime

Remember: The 'use client' directive is a boundary, and the boundary is transitive. The 'use server' directive is a public endpoint, and the endpoint is untrusted. The props are serialized, and serialization is publication. The framework is the runtime, and the runtime is not optional. The cheatsheet is the set of decisions, and the decisions are the discipline.

Was this helpful?


Stop using slow, ad-bloated tool sites! 🤮

🔎 Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
✅ Finance (Mortgage, Interest, Inflation)
✅ Tech (Base64, JSON, Dev Suite, IP)
✅ Health (BMI, BMR, TDEE)
✅ Productivity (Timer, Workspace, QR)

⚡️ Fast & Private
🔒 No data leaves your device
💎 100% Free

🔗 Use it now: https://tools.kandz.me
🔖 Bookmark it—you’ll need it later!