Skip to main content

Nextjs Component Communication

Data flows down. Events flow up. Get this wrong and your app becomes a wiring nightmare.

Every component communication pattern has a cost. Props are explicit but verbose. Context is convenient but hides dependencies. URL state survives navigation but adds complexity. Choose based on scope and lifetime.

Communication Patterns

PatternScopeLifetimeReactivityBest For
PropsParent to childRender cycleAutomaticDirect data passing
Callback propsChild to parentRender cycleManualEvent delegation
React ContextSubtreeProvider mountAutomaticTheme, auth, locale
URL search paramsGlobalNavigationManualFilters, pagination, sharing
Server ComponentsServer to clientRequestNone (static)Initial data, layout
ZustandGlobalApp lifetimeSelectiveClient-side shared state
Server ActionsClient to serverRequestManualMutations, form submissions

Decision Rule

QuestionIf YesIf No
Does only one child need it?PropsKeep reading
Do siblings need it?Lift state or URL paramsKeep reading
Should it survive refresh?URL state or server fetchKeep reading
Is it global client state?ZustandKeep reading
Is it server data?Server Component + fetchReconsider the requirement

Context

Questions

What is the true cost of adding a global state layer?

  • When does prop drilling become a signal to restructure rather than add context?
  • How does the server-client boundary change which patterns are available?
  • What communication patterns become unnecessary with server components?