Next.js

Verified against Claude Code · 2026-07-14

Decide exactly where the client/server boundary belongs in your component tree

Reviews a component tree and pushes every "use client" boundary down to the smallest leaf that actually needs interactivity, with a named reason for each one.

Cursor 2.1Claude CodeGitHub Copilot

The prompt

Ready to copy — highlighted parts are example details you can swap.

<context>
Framework: Next.js App Router, React 19.
Component tree to review: app/dashboard/page.tsx renders <Header>, <RevenueChart interactive filters>, <RecentOrdersTable> with a sort-by-column click handler
What actually needs to be interactive (state, event handlers, browser APIs): Users can filter the revenue chart by date range and click a table header to re-sort orders client-side
</context>

<task>
Go through the component tree above and decide, component by component, whether it should be a Server Component (the default — no directive) or a Client Component ('use client'). Do not default to marking a whole page or layout as a Client Component because one child needs interactivity.
</task>

<decision_rules>
Mark a component 'use client' ONLY if it directly does at least one of:
- calls useState, useReducer, useEffect, or any other React hook that needs the browser
- attaches an event handler (onClick, onChange, onSubmit as a client handler, etc.)
- reads browser-only APIs (window, localStorage, navigator, IntersectionObserver)
- imports a third-party library that itself requires the client (a charting library, a rich-text editor, most drag-and-drop libraries)
- uses React context created with createContext for state that changes at runtime

Everything else stays a Server Component by default, including anything that only fetches data, reads env vars/secrets, or renders static markup.
When a component needs both — server-fetched data AND client interactivity — split it: fetch in a Server Component parent, pass the data down as props/children to a small Client Component that only handles the interactive part. Never lift the boundary higher than the smallest node that actually needs it.
</decision_rules>

<output_format>
A table: Component | Server or Client | One-line reason | If Client, which specific trigger from decision_rules applies.
Then, for any component you'd restructure (split a mixed component into a server parent + client leaf), show the before/after component boundary as a short tree diagram, not full code.
</output_format>
Customize the highlighted detailsoptional — the prompt above already works

Why this works

"use client" is not a per-component opt-in in isolation — it marks a boundary, and everything imported beneath that boundary in the module graph ships to the browser as JS, even server-only-looking children. A generic "is this interactive?" prompt tends to over-mark parents defensively, dragging entire subtrees into the client bundle. Giving the model a closed, checkable list of the actual triggers that require "use client" — hooks, event handlers, browser APIs, client-only libraries — turns a vague architectural judgment call into a per-component checklist it can apply consistently, and the explicit "split, don't lift" rule is the concrete fix for the single most common App Router mistake: marking a whole page "use client" because one child has an onClick handler.

What you get back

Component | Type | Reason Header | Server | Static nav, no state or handlers RevenueChart | Client | Filter state (useState) + onChange handlers for the date range RecentOrdersTable | Split | The table body renders server-fetched rows; only the column-header click handler needs "use client" — split into <OrdersTable> (server, fetches + renders rows) wrapping a small <SortableHeader> (client, owns sort state only)

Verified against

Claude Code Sonnet 4.6 · 2026-07-14

Cursor 2.1 · 2026-07-20

Changelog

  • 2026-07-14 Initial version, tested against Claude Code (Sonnet 4.6) and Cursor 2.1 on Next.js 15/16 App Router projects.

Need this built into your business?

If a prompt isn't enough — custom software, built and maintained for you — that's Scult's day job.

EXPLORE CUSTOM SOFTWARE
All Next.js prompts

Check your AI visibility

One URL in, a 0–100 score and the exact fixes out.

RUN THE CHECK

Browse all the tools

15 tools across six categories
13 of them never send your data anywhere

Free · No signup · No trial clock

SEE THE DIRECTORY