consolelog.tools

Client Component Detector

Detect why a React component needs the 'use client' directive in Next.js

About this ToolHow it works, benefits & use cases

In the Next.js App Router, components are Server Components by default, and forgetting (or unnecessarily adding) the 'use client' directive is a common source of confusing errors. Paste a component here and this detector tells you whether it needs to run on the client and, more usefully, why. It scans the source for client-only signals: React hooks (useState, useEffect, useLayoutEffect, useReducer, useRef), event handlers matched by the on[A-Z] pattern — listing the specific ones it found — browser APIs (window, document, localStorage, sessionStorage, navigator), Context API usage via useContext, and custom hooks that may pull in client features. The result is a verdict banner plus a numbered list of every reason, so instead of guessing you get a concrete checklist of what would have to change to make the component server-renderable. When nothing client-only is detected, it confirms the component can stay on the server and reminds you of the benefits. All analysis runs in your browser.

How to Use

  1. 1Paste your full component source into the "React Component Code" box, including any existing 'use client' directive, or click "Load example".
  2. 2Click "Analyze Component".
  3. 3Read the verdict: "Requires use client" with a numbered reason list, or "Can be a Server Component" when nothing client-only is found.
  4. 4Use the numbered Client Requirements to see exactly which hooks, handlers, or APIs force client rendering.
  5. 5If it can be a Server Component, review the listed benefits, or jump to the Server Component Converter to produce the cleaned-up code.

Key Benefits

  • Explains why a component needs 'use client' with a numbered, specific reason list
  • Names the exact event handlers it finds (for example onClick, onChange) rather than a generic warning
  • Checks hooks, browser APIs, useContext, and custom hooks in one pass
  • Confirms when a component is already server-safe so you can drop the directive
  • Helps trim client-side JavaScript by spotting components that do not need it
  • Links directly to the Server Component Converter for the next step
  • Runs entirely in the browser — paste sensitive component code without it leaving your machine

Common Use Cases

  • Diagnosing a "use client" or hydration error during App Router development
  • Auditing whether a component truly needs to be a Client Component
  • Finding leaf components that can move to the server to shrink the bundle
  • Reviewing a teammate's component before approving a Server/Client boundary
  • Learning which React features are client-only in the Next.js App Router

Paste the full component source — including any 'use client' directive.

What We Check

  • React hooks (useState, useEffect, useReducer, etc.)
  • Event handlers (onClick, onChange, onSubmit, etc.)
  • Browser APIs (window, document, localStorage, etc.)
  • Context API usage (useContext)
  • Custom hooks that may use client features

Was this tool helpful?

Share Your Experience

Help others discover this tool!

Related tools