Deployment & Environment Variables in Next.js Quiz – 15 Questions with Answers
15 questions · 12 min · Medium
Test your knowledge of Server Components and Client Components in Next.js, including rendering strategies, the use client directive, server-side data fetching, React hooks, event handlers, component composition, and performance optimization.
No sign-up needed · Last updated:
Score: 0 00:00
Create a free account to keep your scores and track your progress. It is optional.
15 questions · 12 min · Medium
15 questions · 12 min · Medium
20 questions · 15 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
B. Server Component
Components in the App Router are Server Components by default unless a client boundary is introduced.
A. use client
The use client directive marks a module boundary for Client Components, enabling client-side interactivity and browser-related functionality.
C. Using React useState for interactive state
Client Components can use interactive React features such as useState and useEffect. Server Components do not support these client-side hooks.
D. They can access server-side resources without exposing those resources directly to the browser
Server Components can access databases, server-side APIs, and other server resources. Sensitive credentials must still be handled securely and must not be exposed in client bundles or rendered output.
B. Yes, a Server Component can import and render a Client Component
Server Components can render Client Components as part of the component tree, allowing server-rendered content to include interactive UI.
A. To reduce the amount of code sent to the client and preserve more server-rendered functionality
Keeping client boundaries small can reduce client JavaScript and allow more of the application to benefit from Server Components.
C. useEffect
The useEffect hook runs side-effect logic in Client Components after rendering, according to its dependency configuration.
D. Props must be serializable according to React's supported rules
Props crossing the Server Component to Client Component boundary must follow React's serialization rules. Ordinary functions generally cannot be passed this way, although supported Server Function references are an exception.
B. No, browser-only APIs are unavailable in the server environment
Server Components execute in a server environment, where browser APIs such as window and localStorage are not available. Client-side logic can access them in an appropriate browser context.
A. They can use async functions to fetch data on the server
Server Components can be asynchronous and await data from fetch requests, databases, or other server-side sources before producing their rendered output.
C. Attaching React's client-side behavior to the server-rendered HTML
Hydration allows React to attach event handling and other client-side behavior to HTML that was rendered on the server.
D. Client Component
A button that uses an event handler and updates React state requires Client Component functionality.
B. The module establishes a client boundary, and its imported module dependencies become part of the client bundle where applicable
The directive defines a client entry point. Its client-side dependency graph is included in the client bundle, while unrelated parts of the application can remain Server Components.
A. Fetch the data in a Server Component and isolate the interactive control in a Client Component
Separating server-side data work from interactive client-side behavior can reduce client JavaScript while preserving a responsive user experience.
C. Client Components can be pre-rendered to HTML and then hydrated in the browser
Client Components can contribute server-rendered HTML for the initial page and then become interactive through hydration in the browser.