Question presented to candidate: "Your teammate put 'use client' at the top of the root layout to make an error go away. What does the directive actually do, and where should it go instead?"
What a strong answer should cover:
- 'use client' declares a boundary between the server and client module graphs; it is a file-level directive, placed before the imports.
- Everything the marked file imports becomes part of the client bundle, so it only needs to go on the entry point, not on every child.
- Client Components still render to HTML on the server; the directive adds hydration, it does not turn off server rendering.
- Server Components passed in as
children(or other props) stay on the server even inside a client parent. - Props that cross the boundary must be serializable; state, effects, event handlers and browser APIs are the reasons to add it.
Clarifying questions expected:
- "Which part of the page needs interactivity?" β the directive belongs on that leaf, not on the layout.
- "Is anything in this tree reading secrets or the database?" β that code must not end up below the boundary.
Code / implementation expected: Yes β a small interactive leaf with the directive, used from a server page.