react-nextjs
Skill0 starsChanged 3 months agoMITView on GitHub
Senior-level guidance for building, reviewing, and refactoring React 19 and Next.js (App Router, v15/16) applications in TypeScript — Server vs Client Components, data fetching and caching, Server Actions, forms, state management, performance, auth and security, accessibility, testing, and deployment. Use this skill whenever the user works with React, Next.js, JSX/TSX, hooks, app/ directory, route handlers, middleware/proxy, Server Actions, SSR/SSG/ISR, TanStack Query, Tailwind/shadcn components, or asks for a component, page, hook, layout, form, or frontend architecture decision — even if they only say "frontend", "UI", or "my page is slow/re-rendering". Also use for React/Next.js code review, hydration errors, caching confusion, bundle-size problems, and migrations from the Pages Router.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- maroffo/claude-forgetheir own version, first seen Oct 25, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- maroffo/claude-forge★ 17same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository2 other files it gives its agents.
- en-uz-tech-translateSkill
- laravel-backendSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Write frontend code that is fast by default, correct under async and concurrency, accessible, and easy to delete.
- Very specific: line 15
Derive, don't sync: If a value can be computed from props, state, or the URL, compute it.
- Very specific: line 68
Prefer composition (children, slots, compound components) over configuration props and prop drilling.
- Distinctive: line 71
No components defined inside other components (they remount every render).
- Very specific: line 72
Keep render pure: no mutations, no Date.now()/Math.random() in render for SSR content (hydration mismatch), no side effects.
- Very specific: line 82
After a mutation: revalidate the affected tags/paths, then redirect() (call it outside try/catch.
- Very specific: line 83
Use useActionState for form state and errors, useFormStatus for pending UI inside forms, useOptimistic for instant feedback.
- Very specific: line 108
Don't add memoization (useMemo/useCallback/memo) speculatively.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
React & Next.js (senior discipline)
Write frontend code that is fast by default, correct under async and concurrency, accessible, and easy to delete. The App Router gives several overlapping ways to do everything; this skill says which to pick and why.
Operating principles
- Server first, client by exception. A component is a Server Component until it needs state, effects, event handlers, or browser APIs. Ship less JavaScript instead of optimizing more JavaScript.
- Push
"use client"to the leaves. The directive marks a boundary: everything imported below it joins the client bundle. Keep interactive islands small and pass server-rendered content in viachildren/props. - Treat the server as the source of truth. Fetch where the data is needed, on the server, close to the source. Reach for client-side server-state libraries only for genuinely client-driven data (polling, infinite scroll, optimistic collaboration).
- Derive, don't sync. If a value can be computed from props, state, or the URL, compute it. Every
useEffectthat sets state from other state is a bug waiting to happen. - The URL is state. Filters, tabs, pagination, and search belong in the URL (searchParams / route segments) so they are shareable, back-button-friendly, and server-renderable.
- Every Server Action and Route Handler is a public HTTP endpoint. Authenticate, authorize, and validate inside each one. UI hiding is not security.
- Types are the contract. Strict TypeScript, runtime validation (zod/valibot) at every trust boundary, types inferred from schemas.
- Check the installed version before applying advice. Caching and request APIs changed between Next 14, 15, and 16. Read
package.jsonand match the project; if unsure of an API, check the official docs rather than guessing.
Workflow for non-trivial tasks
- Clarify the unit of work: route, data needed, who may see it, what mutates, what must be interactive, SEO needs.
- Decide the rendering model with the table below; then the data and cache strategy (
references/rsc-and-data.md). - Draw the component tree and mark client boundaries. Keep the client islands minimal.
- Design state (
references/react-patterns.md): URL → server → form → local → shared client, in that order. - Handle the unhappy paths up front: loading (
loading.tsx/Suspense), empty, error (error.tsx), not-found, unauthorized, offline/slow. - Implement following conventions; verify with the checklist at the bottom.
- For auth, input handling, or anything user-generated, read
references/security-auth.md. For tests, a11y, tooling, i18n, and deploy, readreferences/quality-and-ops.md.
Server or Client Component?
| Need | Choice |
| Fetch data, read env secrets, access DB, render static/mostly-static UI | Server Component |
useState, useReducer, useEffect, refs, event handlers, onClick | Client Component |
Browser-only APIs (window, localStorage, IntersectionObserver), most third-party UI libs with hooks | Client Component (wrap the lib once in a small client file) |
| Context provider | Client Component; mount it as low in the tree as practical, pass server children through |
| Interactive widget inside a server-rendered page | Small client island; keep data props serializable |
| Code that must never reach the browser (DB client, secrets) | Mark module with import 'server-only' |
Props crossing server → client must be serializable (no functions except Server Actions, no class instances, no Dates you forgot are converted to strings in JSON). Passing a Server Component as children into a Client Component is allowed and the standard way to avoid bloating the client.
Where does this logic live?
| Concern | Home |
| Reading data for a page | async Server Component calling a data-access function (lib/data/*.ts, server-only) |
| Mutation from a form/button in your own app | Server Action ('use server'), validated + authorized |
| Public/third-party HTTP API, webhooks, file streaming | Route Handler (app/api/**/route.ts) |
| Cross-route redirects/rewrites/headers/geo, cheap checks | middleware.ts (Next ≤15) / proxy.ts (Next 16); never as the only auth gate |
| Authorization of a specific record | Data-access layer, next to the query |
| Reusable stateful logic | Custom hook (useX) in the client tree |
| Shared UI primitives | components/ui/* (design-system level, no data fetching) |
| Feature-specific UI + logic | Colocate in the route segment or features/<name>/ |
| Client-driven async data (polling, infinite scroll, optimistic) | TanStack Query in a client island |
Conventions
Project structure
- Colocate by feature; share only what is truly shared. Prefer
app/(group)/feature/_components/andfeatures/<name>/over a giant globalcomponents/. - Absolute imports via
@/. No barrel files (index.tsre-exports) in hot paths: they defeat tree-shaking and slow dev builds. - One component per file, named export for components (default export only where the framework requires:
page,layout,error, etc.). - Strict TS (
strict,noUncheckedIndexedAccess), ESLint witheslint-plugin-react-hooks(+ React Compiler rules if enabled), Prettier,tsc --noEmitin CI.
Components
- Props: small, typed, explicit; use discriminated unions for variants instead of boolean piles (
variant: 'link' | 'button'with conditional props). - Prefer composition (
children, slots, compound components) over configuration props and prop drilling. - Accept
classNameand spread remaining props (React.ComponentProps<'button'>) in UI primitives. React 19:refis a normal prop;forwardRefis no longer needed for new code. - Stable, meaningful
keys (IDs, never array index for reorderable lists). Changingkeyis the clean way to reset component state. - No components defined inside other components (they remount every render).
- Keep render pure: no mutations, no
Date.now()/Math.random()in render for SSR content (hydration mismatch), no side effects.
Data & caching (summary; details in reference)
paramsandsearchParamsare async in Next 15+:const { id } = await params. Same forcookies()andheaders().- Parallelize independent fetches (
Promise.all) and stream slow parts with<Suspense>instead of blocking the whole page. - Deduplicate within a request with React
cache()for non-fetchdata access. - Be explicit about caching: tag data and revalidate on mutation. Never rely on remembering the framework default.
Mutations
- Validate input with zod; return a typed result (
{ ok: true, data } | { ok: false, fieldErrors }) rather than throwing for expected failures. - After a mutation: revalidate the affected tags/paths, then
redirect()(call it outsidetry/catch; it works by throwing). - Use
useActionStatefor form state and errors,useFormStatusfor pending UI inside forms,useOptimisticfor instant feedback; progressive enhancement comes free when you use<form action={...}>.
Styling & UI
- Tailwind + a headless primitive layer (Radix/shadcn/Base UI) beats bespoke widgets for accessibility. Don't hand-roll dialogs, comboboxes, menus, tooltips.
next/imagefor images (setsizes,priorityonly for the LCP image),next/fontfor fonts (no layout shift),next/linkfor navigation,next/scriptfor third-party scripts with the rightstrategy.
Review checklist (run before presenting code)
"use client"only where needed and as deep in the tree as possible; no server-only code or secrets reachable from client modules.- Props crossing the boundary are serializable; nothing sensitive is passed to a Client Component (it ends up in the HTML/RSC payload).
- No data fetching in
useEffectwhen a Server Component or Server Action would do; no state that duplicates props/URL. - Every Server Action/Route Handler: authenticates, authorizes the specific resource, validates input, handles errors.
- Loading, empty, error, and not-found states exist for each async segment; Suspense boundaries are placed where they help.
- Caching strategy is explicit (tags/revalidate/
use cache/dynamic) and mutations invalidate it. - No hydration hazards (browser-only values or time/random in initial render; invalid HTML nesting).
- Lists have stable keys; no components defined inside components; effects have correct dependencies and cleanup.
- Forms have labels, errors tied to inputs (
aria-describedby), keyboard operability, visible focus. - Types are strict; no
any/uncheckedas; external data validated at the edge. - Bundle impact considered: heavy libs lazy-loaded (
next/dynamic/import()), no barrel imports, images/fonts optimized. - Tests cover the behavior that matters (user-visible flow, auth rules, validation); lint, type-check, and tests pass.
How to respond
- Match the project's existing conventions, Next/React versions, and libraries before applying these defaults.
- In code review, lead with correctness/security/data-leak issues, then performance and UX, then style. Give concrete fixes.
- Provide complete, runnable TSX (imports, types, file path as a comment on the first line, e.g.
// app/orders/page.tsx). - Explain non-obvious choices in a sentence; when a trade-off is genuine (Server Action vs Route Handler, TanStack Query vs RSC), choose one, justify, and say when you'd switch.
- Don't add memoization (
useMemo/useCallback/memo) speculatively. Measure first; with the React Compiler enabled it is mostly unnecessary.
Reference files
references/rsc-and-data.md— rendering modes, streaming, fetching and caching (Next 15 vs 16), revalidation, Server Actions, route handlers, error/loading boundaries.references/react-patterns.md— state placement, effects, forms, custom hooks, performance and re-render control, React 19 APIs, React Compiler, TanStack Query.references/security-auth.md— authN/authZ placement, data-access layer, cookies/sessions, XSS/CSRF/SSRF, env vars, headers/CSP, uploads.references/quality-and-ops.md— testing, TypeScript, accessibility, SEO/metadata, i18n, observability, build/deploy, migration notes.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

