Server and Client Components — Concept Check
Questions on Server and Client Components. Everything is a server component until a file says otherwise. Knowing exactly what "use client" does — and what it does not — is the single most important thing in the App Router.
Questions in this quiz
8 questions on Server and Client Components — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A developer places 'use client' at the top of a component file. What does this imply?
- AThe component and its imports are included in the client bundle and hydrate.
- BThe component will not render any initial HTML on the server.
- CThe component will only render in the browser, not on the server.
- DThe component cannot import any server-only code.
2.You notice a page's load time increases significantly after adding a 'use client' directive at the top of a component. What is likely happening?
- AThe component is no longer rendering on the server, causing delays.
- BThe 'use client' directive is causing an error in server-side rendering.
- CThe component's server-side functionality has been disabled.
- DThe entire component tree is now part of the client bundle, increasing load time.
3.A developer wants to keep a page mostly server-rendered but needs an interactive button. What is the best approach?
- AMake the button a client component and keep the rest server-rendered.
- BApply 'use client' at the top of the page file.
- CUse server components for everything, including the button.
- DConvert the entire page to a client component for simplicity.
4.What happens if you pass a database client instance as a prop to a client component?
- AIt results in an error because class instances cannot be serialized.
- BThe client component will serialize the instance and function normally.
- CThe client component will fail to render but no error will be shown.
- DThe database client will be converted to a plain object automatically.
5.Why might a developer use the 'children as a slot' pattern in client components?
- ATo keep server-rendered content from becoming part of the client bundle.
- BTo ensure all content is rendered in the browser for interactivity.
- CTo prevent any server-side rendering from occurring.
- DTo make sure all components are client components by default.
6.A component needs to use 'useState'. What must be true for it to work correctly?
- AThe component cannot import any server-side libraries.
- BThe component or its parent must have 'use client' specified.
- CThe component must not use any event handlers.
- DThe component must be rendered only on the client side.
7.Which of the following can be serialized and passed from a server component to a client component?
- AA function defined in the server component.
- BA library object like dayjs().
- CA plain object containing strings and numbers.
- DAn instance of a custom class.
8.What is a potential security risk when passing props to a client component?
- ASensitive data can be exposed in the HTML payload.
- BThe client component might not render correctly.
- CThe client component could fail to load due to serialization issues.
- DServer-side data might not update in real-time.