Skip to main content
InterviewHubPRO
Section Overview
Q6

Question 6 of 50

Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

12%
Next.js & App Router (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

When should you use the `'use client'` directive?

junior LevelDirectivesCLI

In Simple Words: You only need to add 'use client' at the top of a file when the component requires:

  1. React hooks: useState, useReducer, useEffect, useRef.
  2. Interactive DOM event listeners: onClick, onChange, onSubmit.
  3. Browser APIs: window, document, navigator, localStorage.
  4. Custom hooks that depend on client state or context providers.

Rule of Thumb: Push 'use client' down to the leaves of your component tree. Keep parents as Server Components.