/frontend-ui:typescript-react-nextjs-patternsfrom frontend-ui
Production-grade TypeScript reference for React & Next.js frontend development. Covers type narrowing, component Props, generic hooks, discriminated unions, Zod validation, TanStack Query, server/client boundaries, forms, state management, performance, accessibility, debugging, and code review.
Ships in frontend-ui. 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.
Read when SKILL.md points to them.
A structured reference for AI coding agents assisting frontend engineers with TypeScript, React, and Next.js in production environments.
"use client" components.satisfies needs 5.0+, NoInfer 5.4+, inferred type predicates 5.5+. TS 6.0 is the final JS-based compiler; TS 7 is the Go-native rewrite — ~10x faster, same language, but tooling that consumes the old compiler API may lag.params is a Promise in 15+. Caching model changed in 16+ ("use cache"), and 16 renames middleware.ts → proxy.ts (Node runtime).ref a regular prop (forwardRef deprecated), renders <Context> directly, and replaces useFormState with useActionState. useEffectEvent and <Activity> need 19.2+.searchParams values are the expected type (they are always string | string[] | undefined)any in existing code is intentionalas) is justified without checking contextuseEffect dependencies in existing code are correctIf this session was compacted and the rules content survives only as a summary:
HARD-RULES.md first — every non-negotiable rule in compressed form.| Situation | Start here |
|---|---|
| Typing component Props, children, events, refs | → react-typescript-patterns.md |
Narrowing unions, unknown, type guards, utility types | → typescript-core.md |
| Next.js params, searchParams, Server Actions, RSC boundary | → nextjs-typescript.md |
| Discriminated unions, conditional props, compound components | → component-patterns.md |
| API responses, fetch typing, TanStack Query, caching | → data-fetching-and-api-types.md |
| Form state, validation, controlled vs uncontrolled | → forms-and-validation.md |
| Local state vs context vs server state vs Zustand | → state-management.md |
| Re-renders, memoization, accessibility | → performance-and-accessibility.md |
| Type errors, hydration, stale state, effect bugs | → debugging-checklists.md (hub) + playbooks/ |
| PR review, risk vs preference, architecture smells | → code-review-rules.md |
| Common mistakes, cargo-cult patterns | → anti-patterns.md |
Data comes from...
├─ Inside the app (useState, useReducer, computed)
│ → Static typing is sufficient. No runtime validation needed.
│
├─ Outside the app (API, URL, FormData, localStorage, postMessage)
│ → [HARD RULE] Validate at runtime. Use Zod or equivalent.
│ │
│ ├─ API response → schema.parse(await res.json())
│ ├─ URL params → schema.parse(searchParams)
│ ├─ FormData → schema.safeParse({ field: formData.get('field') })
│ ├─ localStorage → schema.safeParse(JSON.parse(stored))
│ └─ postMessage → schema.safeParse(event.data)
│
└─ Third-party library callback
→ Check library types. Add runtime guard if types seem wrong.
Is this data from a server/API?
├─ Yes → TanStack Query (NOT useState). See data-fetching-and-api-types.md
│
└─ No → Is it shareable via URL? (filters, page, sort)
├─ Yes → searchParams or nuqs. See state-management.md
│
└─ No → How many components need it?
├─ 1 component → useState or useReducer
├─ 2-3 in same tree → Lift state up (props)
└─ Many across trees → How often does it change?
├─ Rarely (theme, locale, auth) → Context
└─ Often (cart, notifications) → Zustand with selectors
Is there a measured performance problem?
├─ No → Don't memoize. Stop here.
│
└─ Yes → Can you restructure instead?
├─ Yes → Move state down, extract components. See performance-and-accessibility.md
│
└─ No → What needs memoizing?
├─ Expensive computation → useMemo (verify it's truly expensive)
├─ Callback to memoized child → useCallback
└─ Component in a long list → React.memo (verify props are stable)
| Label | Meaning | Example |
|---|---|---|
| [HARD RULE] | Violating causes bugs or security issues. No exceptions. | "Validate API responses at runtime" |
| [DEFAULT] | Recommended unless you have a documented reason to deviate. | "Use interface for Props" |
| [SITUATIONAL] | Depends on context. Both options are valid. Explain your choice. | "Polymorphic components — only for design-system foundations" |
Before generating TypeScript/React/Next.js code:
Context
Type Safety
any — use unknown with validation or proper typesas without documented justificationinterface, only truly optional fields have ?React
children typed as React.ReactNode"use client" only where needed, as deep as possibleuseStateNext.js (15+)
params and searchParams awaitedimport 'server-only'Date/Map/Set/Promise are fine)Accessibility
role="alert"any without documented reasonas on external data without validation! non-null assertion without prior guarduseEffect with object/array dependencies (likely unstable)useEffect cleanupuseState"use client" at page/layout levelparams/searchParams not awaited (Next.js 15+)type vs interface for object shapes| File | Scope |
|---|---|
HARD-RULES.md | All [HARD RULE]s in one page — compaction recovery, CLAUDE.md embedding, hook injection |
typescript-core.md | Narrowing, unions, generics, utility types, inference, unknown vs any, as const, satisfies |
react-typescript-patterns.md | Props, children, events, refs (19 ref-as-prop / 18 forwardRef), hooks, context |
nextjs-typescript.md | App Router types, params, searchParams, Server Actions, RSC boundaries, Cache Components (16), proxy.ts, metadata |
component-patterns.md | Discriminated union Props, compound components, controlled/uncontrolled, polymorphic |
data-fetching-and-api-types.md | Fetch typing, Zod validation, TanStack Query, safe response handling |
forms-and-validation.md | Form state, Zod, react-hook-form, Server Actions, progressive enhancement |
state-management.md | Local state, Context, Zustand, TanStack Query, URL state, decision matrix |
performance-and-accessibility.md | Memoization tradeoffs, effect stability, semantic HTML, ARIA patterns |
debugging-checklists.md | Quick diagnosis router, serialization issues, null access, re-render errors |
code-review-rules.md | Risk vs preference, architecture smells, review comment templates |
anti-patterns.md | 13 common mistakes with root causes and fixes |
playbooks/ — Step-by-step debugging guides (consult when diagnosing specific bugs)| File | Scope |
|---|---|
type-error-debugging.md | Systematic type error resolution with React/Next.js-specific errors |
hydration-issues.md | SSR/CSR mismatch diagnosis flowchart and fix patterns |
effect-dependency-bugs.md | Infinite loops, stale closures, missing cleanups, real-world debounce example |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub skillmds/skillmd --plugin frontend-ui30 skills in this plugin
/ads-landingAudit paid-ad landing pages for message match, mobile experience, performance, accessibility, trust, forms, consent, tracking, security, and conversion friction. Use for landing-page audit, post-click experience, LP audit, conversion-rate optimization, form optimization, ad-to-page message match, redirects, blocked navigation, or requests involving private, loopback, link-local, or metadata IP destinations./ads-reportRender Markdown, HTML, or PDF paid-advertising reports from a validated Claude Ads JSON run bundle. Use for ads report, client report, audit PDF, executive audience reporting, or exporting prior audit and plan results./dark-modeImplement complete dark mode for any frontend project. Auto-detects theme system (Flutter ThemeData, Tailwind dark class, CSS variables, MUI, Chakra UI, styled-components), generates a dark color palette with proper surface elevation hierarchy and desaturated brand colors, creates a theme toggle with system preference detection and persistence, migrates all hardcoded colors to theme tokens, handles special cases like images, shadows, form inputs, and charts, then verifies WCAG AA contrast ratios for both modes. Use when you need to add dark mode, fix dark theme contrast issues, create a theme switcher, or migrate hardcoded colors to theme-aware tokens.2 plugins in one repository ship this exact skill · first indexed Oct 4, 2026
Other plugins' skills for the same job