'use client'
A string placed at the top of a file that marks its components as client components, sent to and run in the browser.
In more detail
In frameworks with React Server Components, such as Next.js, a file without it is treated as server code. Hooks and event handlers then fail, so bundled interactive primitives keep the directive at the top of their output files.
Related terms
- React Server Components — React components that run only on the server, sending their rendered result to the browser without shipping their code.
- Next.js — A React framework for building web applications that can render pages on the server and supports React Server Components.
- hydration — The step where React in the browser attaches event handlers and state to HTML that was already rendered on the server.
Taught in
- Component Packaging: Dual ESM/CJS Builds & Package Exports — Design Systems & Component Engineering