/nextjs-stack:reactfrom nextjs-stack
React and Next.js App Router frontend architecture: composition, the Server/Client boundary, data and state, streaming, performance and the frontend's security share, each rule with its enforcement. Use when writing or reviewing React components in a Next.js project.
Ships in nextjs-stack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Patterns that hold and anti-patterns that bite, for React 19.3 with the Next.js 16.4 App Router. Every rule here was checked against react.dev and the Next.js docs on 2026-10-21; each cites the page it comes from. The layers are the same eight that the Hotwire architecture uses, so the two stacks compare row for row; the stack-neutral contracts behind them (shell, regions, the UX and performance contracts) are the design system's.
Enforcement. Every rule names what holds it:
eslint-config-next already turns on; run the project's lint.react-patterns / react-lint-off-by-default: nextjs-stack's own checks (checks.json), run by /rails-flow:gates.react-hooks/static-components). react.dev: preserving and resetting statechildren before drilling props. When a component only forwards props it does not use, pass the JSX as children; reach for context only when props and composition do not fit. Enforcement: verified advice (a recorded-verdict rule once #2225 lands). react.dev: passing data deeply with contextMath.random()) remounts every item. An index is fine for a list that never reorders. Enforcement: default lint (react/jsx-key, react-hooks/purity) and react-lint-off-by-default (react/no-array-index-key). react.dev: rendering lists"use client" only for state, effects, custom hooks, event handlers or browser-only APIs. Enforcement: verified advice (a recorded-verdict rule once #2225 lands); a check cannot see whether a third-party import is the reason a module needs the client. Next.js: Server and Client Components<Link>. It does client-side navigation and prefetches in production (a static route fully, a dynamic route down to its nearest loading.js); a plain <a> to an internal route reloads the whole page. Enforcement: react-patterns (internal-anchor; the Next lint rule only reads a pages/ directory). Next.js: Linkerror.js is a Client Component that contains an error to its segment (errors bubble to the nearest boundary; event handlers and async code are not caught); not-found.js renders for notFound(). Enforcement: verified advice (a recorded-verdict rule once #2225 lands). Next.js: error handling"use client" on the smallest interactive leaf. A high boundary does not lose server rendering (Client Components still prerender HTML), but the subtree loses Server Components and ships more JavaScript. The boundary covers a module's imports and the components it renders directly, not Server Components passed to it as children or props. Enforcement: react-patterns (use-client-route-file), passed by declaration when a client route is a deliberate trade-off: a comment react-architecture: client-route -- <reason> in that file. Next.js: Server and Client Components<Suspense>, close to the data, or add loading.js to the segment, so the rest of the page is not blocked by its slowest fetch. A layout that reads uncached data blocks, because it does not fall back to its own segment's loading.js. Enforcement: verified advice (a recorded-verdict rule once #2225 lands). Next.js: fetching datasetState (that renders once with a stale value, then again). Use useMemo only when the computation is expensive: measure first. Enforcement: default lint (react-hooks/set-state-in-effect flags the shape). react.dev: you might not need an Effectkey, not an Effect. Enforcement: default lint (same rule). react.dev: you might not need an EffectuseMemo / useCallback. memo does not stop a context re-render. Enforcement: react-lint-off-by-default (react/jsx-no-constructed-context-values). react.dev: useContextuse or a data library (SWR, React Query); an Effect that does fetch needs cleanup to ignore stale responses. Enforcement: react-patterns (fetch-in-effect). react.dev: synchronizing with EffectsPromise.all (or Promise.allSettled when one failure must not fail the rest). Enforcement: verified advice (a recorded-verdict rule once #2225 lands). Next.js: fetching dataThe loading, empty, error, optimistic and focus states are the design system's contract; React's part is the streaming and boundaries in layers 2 and 3, and:
next/image and next/font, which avoid layout shift (a remote image needs width/height or fill); a raw <img> loses that. Enforcement: default lint (@next/next/no-img-element, google-font-display, google-font-preconnect). Next.js: imagesuseMemo, useCallback or memo; when it does not, fix the cause. Rely on the React Compiler for new code, keep manual memoisation as an escape hatch (for example Effect dependencies), and do not strip existing memoisation without testing. Enforcement: verified advice (a recorded-verdict rule once #2225 lands). react.dev: useMemo · React Compiler 1.0next/dynamic / React.lazy to shrink the initial bundle. Server Components are split automatically; a Server Component that dynamically imports a Client Component gets no splitting from it. Enforcement: verified advice (a recorded-verdict rule once #2225 lands). Next.js: lazy loadingThe other performance rules sit with their layer: stable component types and keys (1), the client boundary and streaming (3), context values and parallel fetching (4), images and fonts (5).
nextjs-stack's security surface (the checklist, scanners and boundary patterns) is its own issue, #2210. The frontend architecture states only these:
dangerouslySetInnerHTML only with trusted, sanitised data. It bypasses React's escaping. Enforcement: react-lint-off-by-default (react/no-danger flags every use; keep it for sanitised markup only). react.dev: common componentsNEXT_PUBLIC_ variable. Keep secrets in Server Components and mark server-only modules with import "server-only" (a build error if a client module imports it). Enforcement: the framework's build error; the key seam is in the nextjs-supabase-vercel skill. Next.js: data security| anti-pattern | rule | what catches it |
|---|---|---|
| a component defined inside a component | 1 | default lint |
an index or random key | 1 | default lint + react-lint-off-by-default |
| derived state or a prop reset in an Effect | 4 | default lint |
| an inline object as a context value | 4 | react-lint-off-by-default |
"use client" on a route file, unexplained | 3 | react-patterns + declaration |
fetch in a client Effect | 4 | react-patterns |
an internal <a> | 2 | react-patterns |
a raw <img>, unoptimised fonts | 5 | default lint |
unsanitised dangerouslySetInnerHTML | 7 | react-lint-off-by-default |
| a Server Action without its own auth check | 7 | the security surface (#2210) |
prop drilling, a component with many concerns, state too high or duplicated, memoisation as a band-aid, an unneeded "use client", sequential independent fetches, missing boundaries or streaming | 1–6 | verified advice; a recorded verdict once #2225 lands |
When the recorded-verdict mechanism (rails-flow #2225) lands, a PR that changes React components will need a verdict for each of these; until then they are verified advice and nothing refuses a PR for them. The registry format will be #2225's; this list is the declaration to move into it:
compose-through-children, one-concern-per-component, server-components-by-default, segment-boundaries, stream-slow-parts, lift-shared-state, keep-state-local, parallel-requests, memoisation-not-a-fix, lazy-load-heavy-client.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
2 skills in this plugin
npx claudepluginhub fmanimashaun/claude-skills --plugin nextjs-stack