name: nextjs-senior-dev
description: Senior Next.js 15+/16 Engineer skill for App Router. Use when scaffolding production apps, enforcing RSC patterns, auditing codebases, or optimizing performance.
author: George Khananaev
version: 1.3.0
Next.js Senior Developer
Transform into Senior Next.js 15+/16 Engineer for production-ready App Router applications.
When to Use
- Scaffolding new Next.js App Router projects
- RSC vs Client Component decisions
- Server Actions and data fetching patterns
- Performance optimization (CWV, bundle, caching)
- Middleware and authentication setup
- Next.js 15/16 migration or audit
Version Notes
| Version |
Key Changes |
| Next.js 16 |
middleware.ts → proxy.ts, Node.js runtime only, Cache Components |
| Next.js 15 |
fetch uncached by default, React 19, Turbopack stable |
Triggers
| Command |
Purpose |
/next-init |
Scaffold new App Router project |
/next-route |
Generate route folder (page, layout, loading, error) |
/next-audit |
Audit codebase for patterns, security, performance |
/next-opt |
Optimize bundle, images, fonts, caching |
Reference Files (23 Total)
Load based on task context:
Core References
| Category |
Reference |
When |
| Routing |
references/app_router.md |
Route groups, parallel, intercepting |
| Components |
references/components.md |
RSC vs Client decision, patterns |
| Data |
references/data_fetching.md |
fetch, cache, revalidation, streaming |
| Security |
references/security.md |
Server Actions, auth, OWASP |
| Performance |
references/performance.md |
CWV, images, fonts, bundle, memory |
| Middleware |
references/middleware.md |
Auth, redirects, Edge vs Node |
Architecture & Quality
| Category |
Reference |
When |
| Architecture |
references/architecture.md |
File structure, feature-sliced design |
| Shared Components |
references/shared_components.md |
DRY patterns, composition, reusability |
| Code Quality |
references/code_quality.md |
Error handling, testing, accessibility |
Features & Integrations
| Category |
Reference |
When |
| SEO & Metadata |
references/seo_metadata.md |
generateMetadata, sitemap, OpenGraph |
| Database |
references/database.md |
Prisma, Drizzle, queries, migrations |
| Authentication |
references/authentication.md |
Auth.js, sessions, RBAC |
| Forms |
references/forms.md |
React Hook Form, Zod, file uploads |
| i18n |
references/i18n.md |
next-intl, routing, RTL support |
| Real-Time |
references/realtime.md |
SSE, WebSockets, polling, Pusher |
| API Design |
references/api_design.md |
REST, tRPC, webhooks, versioning |
DevOps & Migration
| Category |
Reference |
When |
| Deployment |
references/deployment.md |
Vercel, Docker, CI/CD, env management |
| Monorepo |
references/monorepo.md |
Turborepo, shared packages, workspaces |
| Migration |
references/migration.md |
Pages→App Router, version upgrades |
| Debugging |
references/debugging.md |
DevTools, profiling, error tracking |
| Scripts & 3rd-Party |
references/scripts.md |
next/script, loading strategies, Google Analytics |
| Self-Hosting |
references/self_hosting.md |
Docker standalone, cache handlers, multi-instance ISR |
| Debug Tricks |
references/debug_tricks.md |
MCP debugging, --debug-build-paths |
Core Tenets
1. Server-First
Default to Server Components. Use Client only when required.
RSC when: data fetching, secrets, heavy deps, no interactivity
Client when: useState, useEffect, onClick, browser APIs
2. Component Archetypes
| Pattern |
Runtime |
Must Have |
page.tsx |
Server |
async, data fetching |
*.action.ts |
Server |
"use server", Zod, 7-step security |
*.interactive.tsx |
Client |
"use client", event handlers |
*.ui.tsx |
Either |
Pure presentation, stateless |
3. 7-Step Server Action Security
"use server"
// 1. Rate limit (IP/user)
// 2. Auth verification
// 3. Zod validation (sanitize errors!)
// 4. Authorization check (IDOR prevention)
// 5. Mutation
// 6. Granular revalidateTag() (NOT revalidatePath)
// 7. Audit log (async)
4. Data Fetching Strategy
Static → generateStaticParams + fetch
ISR → fetch(url, { next: { revalidate: 60 }})
Dynamic → fetch(url, { cache: 'no-store' })
Real-time → Client fetch (SWR)
Next.js 15 Change: fetch is UNCACHED by default (opposite of 14).
5. Caching
| Type |
Scope |
Invalidation |
| Request Memoization |
Request |
Automatic |
| Data Cache |
Server |
revalidateTag() |
| Full Route Cache |
Server |
Rebuild |
| Router Cache |
Client |
router.refresh() |
Prefer revalidateTag() over revalidatePath() to avoid cache storms.
6. Feature-Sliced Architecture
For large apps (50+ routes), use domain-driven structure:
src/
├── app/ # Routing only
├── components/ # Shared UI (ui/, shared/)
├── features/ # Business logic per domain
│ └── [feature]/
│ ├── components/
│ ├── actions/
│ ├── queries/
│ └── hooks/
├── lib/ # Global utilities
└── types/ # Global types
7. Component Sharing Rules
| Used 3+ places? |
Contains business logic? |
Action |
| Yes |
No |
Move to components/ui/ or shared/ |
| Yes |
Yes |
Keep in features/ |
| No |
Any |
Keep local (_components/) |
8. State Management Hierarchy
| State Type |
Tool |
Example |
| URL State |
searchParams |
Filters, pagination |
| Server State |
Server Components |
User data, posts |
| Form State |
useFormState |
Form submissions |
| UI State |
useState |
Modals, dropdowns |
| Shared Client |
Context/Zustand |
Theme, cart |
Rule: Prefer URL state for shareable/bookmarkable state.
9. DRY with createSafeAction
// lib/safe-action.ts - Reuse for all Server Actions
export const createPost = createSafeAction(schema, handler, {
revalidateTags: ["posts"]
})
Eliminates duplicate auth/validation/error handling.
Anti-Patterns
| Don't |
Do |
| "use client" at tree root |
Push boundary down to leaves |
| API routes for server data |
Direct DB in Server Components |
| useEffect for fetching |
Server Component async fetch |
| revalidatePath('/') |
Granular revalidateTag() |
| Trust middleware alone |
Validate at data layer too |
| Prop drill 5+ levels |
Context or composition |
any types |
Proper types or unknown |
| Barrel exports in features |
Direct imports |
| localStorage for auth |
httpOnly cookies |
| Global caches (memory leak) |
LRU cache or React cache() |
Middleware: Deny by Default
// middleware.ts - Public routes MUST be allowlisted
const publicRoutes = ['/login', '/register', '/api/health']
if (!publicRoutes.some(r => pathname.startsWith(r))) {
// Require auth
}
CRITICAL: Upgrade to Next.js 15.2.3+ (CVE-2025-29927 fix).
Scripts
| Script |
Purpose |
scripts/scaffold_route.py |
Generate route folder w/ all files |
Templates
| File |
Purpose |
templates/page.tsx |
Standard async page |
templates/layout.tsx |
Layout w/ metadata |
templates/action.ts |
7-step secure Server Action |
templates/loading.tsx |
Loading UI skeleton |
templates/error.tsx |
Error boundary |
Assets
| File |
Purpose |
assets/next.config.ts |
Production config w/ security headers |
assets/middleware.ts |
Deny-by-default auth (Next.js 15) |
assets/proxy.ts |
Deny-by-default auth (Next.js 16+) |
Quick Reference: Senior Code Review
Before merging any PR, verify:
Performance
Security
Architecture
Quality
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: georgekhananaev-claude-skills-vault-nextjs-senior-dev3description: ---4---5---6name: nextjs-senior-dev7description: Senior Next.js 15+/16 Engineer skill for App Router. Use when scaffolding production apps, enforcing RSC patterns, auditing codebases, or optimizing performance.8author: George Khananaev9version: 1.3.010---1112# Next.js Senior Developer1314Transform into Senior Next.js 15+/16 Engineer for production-ready App Router applications.1516## When to Use1718- Scaffolding new Next.js App Router projects19- RSC vs Client Component decisions20- Server Actions and data fetching patterns21- Performance optimization (CWV, bundle, caching)22- Middleware and authentication setup23- Next.js 15/16 migration or audit2425## Version Notes2627| Version | Key Changes |28|---------|-------------|29| Next.js 16 | `middleware.ts` → `proxy.ts`, Node.js runtime only, Cache Components |30| Next.js 15 | fetch uncached by default, React 19, Turbopack stable |3132## Triggers3334| Command | Purpose |35|---------|---------|36| `/next-init` | Scaffold new App Router project |37| `/next-route` | Generate route folder (page, layout, loading, error) |38| `/next-audit` | Audit codebase for patterns, security, performance |39| `/next-opt` | Optimize bundle, images, fonts, caching |4041## Reference Files (23 Total)4243Load based on task context:4445### Core References4647| Category | Reference | When |48|----------|-----------|------|49| Routing | `references/app_router.md` | Route groups, parallel, intercepting |50| Components | `references/components.md` | RSC vs Client decision, patterns |51| Data | `references/data_fetching.md` | fetch, cache, revalidation, streaming |52| Security | `references/security.md` | Server Actions, auth, OWASP |53| Performance | `references/performance.md` | CWV, images, fonts, bundle, memory |54| Middleware | `references/middleware.md` | Auth, redirects, Edge vs Node |5556### Architecture & Quality5758| Category | Reference | When |59|----------|-----------|------|60| Architecture | `references/architecture.md` | File structure, feature-sliced design |61| Shared Components | `references/shared_components.md` | DRY patterns, composition, reusability |62| Code Quality | `references/code_quality.md` | Error handling, testing, accessibility |6364### Features & Integrations6566| Category | Reference | When |67|----------|-----------|------|68| SEO & Metadata | `references/seo_metadata.md` | generateMetadata, sitemap, OpenGraph |69| Database | `references/database.md` | Prisma, Drizzle, queries, migrations |70| Authentication | `references/authentication.md` | Auth.js, sessions, RBAC |71| Forms | `references/forms.md` | React Hook Form, Zod, file uploads |72| i18n | `references/i18n.md` | next-intl, routing, RTL support |73| Real-Time | `references/realtime.md` | SSE, WebSockets, polling, Pusher |74| API Design | `references/api_design.md` | REST, tRPC, webhooks, versioning |7576### DevOps & Migration7778| Category | Reference | When |79|----------|-----------|------|80| Deployment | `references/deployment.md` | Vercel, Docker, CI/CD, env management |81| Monorepo | `references/monorepo.md` | Turborepo, shared packages, workspaces |82| Migration | `references/migration.md` | Pages→App Router, version upgrades |83| Debugging | `references/debugging.md` | DevTools, profiling, error tracking |84| Scripts & 3rd-Party | `references/scripts.md` | next/script, loading strategies, Google Analytics |85| Self-Hosting | `references/self_hosting.md` | Docker standalone, cache handlers, multi-instance ISR |86| Debug Tricks | `references/debug_tricks.md` | MCP debugging, --debug-build-paths |8788## Core Tenets8990### 1. Server-First9192Default to Server Components. Use Client only when required.9394```95RSC when: data fetching, secrets, heavy deps, no interactivity96Client when: useState, useEffect, onClick, browser APIs97```9899### 2. Component Archetypes100101| Pattern | Runtime | Must Have |102|---------|---------|-----------|103| `page.tsx` | Server | async, data fetching |104| `*.action.ts` | Server | "use server", Zod, 7-step security |105| `*.interactive.tsx` | Client | "use client", event handlers |106| `*.ui.tsx` | Either | Pure presentation, stateless |107108### 3. 7-Step Server Action Security109110```typescript111"use server"112// 1. Rate limit (IP/user)113// 2. Auth verification114// 3. Zod validation (sanitize errors!)115// 4. Authorization check (IDOR prevention)116// 5. Mutation117// 6. Granular revalidateTag() (NOT revalidatePath)118// 7. Audit log (async)119```120121### 4. Data Fetching Strategy122123```124Static → generateStaticParams + fetch125ISR → fetch(url, { next: { revalidate: 60 }})126Dynamic → fetch(url, { cache: 'no-store' })127Real-time → Client fetch (SWR)128```129130**Next.js 15 Change**: fetch is UNCACHED by default (opposite of 14).131132### 5. Caching133134| Type | Scope | Invalidation |135|------|-------|--------------|136| Request Memoization | Request | Automatic |137| Data Cache | Server | revalidateTag() |138| Full Route Cache | Server | Rebuild |139| Router Cache | Client | router.refresh() |140141Prefer `revalidateTag()` over `revalidatePath()` to avoid cache storms.142143### 6. Feature-Sliced Architecture144145For large apps (50+ routes), use domain-driven structure:146147```148src/149├── app/ # Routing only150├── components/ # Shared UI (ui/, shared/)151├── features/ # Business logic per domain152│ └── [feature]/153│ ├── components/154│ ├── actions/155│ ├── queries/156│ └── hooks/157├── lib/ # Global utilities158└── types/ # Global types159```160161### 7. Component Sharing Rules162163| Used 3+ places? | Contains business logic? | Action |164|-----------------|-------------------------|--------|165| Yes | No | Move to `components/ui/` or `shared/` |166| Yes | Yes | Keep in `features/` |167| No | Any | Keep local (`_components/`) |168169### 8. State Management Hierarchy170171| State Type | Tool | Example |172|------------|------|---------|173| URL State | searchParams | Filters, pagination |174| Server State | Server Components | User data, posts |175| Form State | useFormState | Form submissions |176| UI State | useState | Modals, dropdowns |177| Shared Client | Context/Zustand | Theme, cart |178179**Rule**: Prefer URL state for shareable/bookmarkable state.180181### 9. DRY with createSafeAction182183```typescript184// lib/safe-action.ts - Reuse for all Server Actions185export const createPost = createSafeAction(schema, handler, {186 revalidateTags: ["posts"]187})188```189190Eliminates duplicate auth/validation/error handling.191192## Anti-Patterns193194| Don't | Do |195|-------|-----|196| "use client" at tree root | Push boundary down to leaves |197| API routes for server data | Direct DB in Server Components |198| useEffect for fetching | Server Component async fetch |199| revalidatePath('/') | Granular revalidateTag() |200| Trust middleware alone | Validate at data layer too |201| Prop drill 5+ levels | Context or composition |202| `any` types | Proper types or `unknown` |203| Barrel exports in features | Direct imports |204| localStorage for auth | httpOnly cookies |205| Global caches (memory leak) | LRU cache or React cache() |206207## Middleware: Deny by Default208209```typescript210// middleware.ts - Public routes MUST be allowlisted211const publicRoutes = ['/login', '/register', '/api/health']212if (!publicRoutes.some(r => pathname.startsWith(r))) {213 // Require auth214}215```216217**CRITICAL**: Upgrade to Next.js 15.2.3+ (CVE-2025-29927 fix).218219## Scripts220221| Script | Purpose |222|--------|---------|223| `scripts/scaffold_route.py` | Generate route folder w/ all files |224225## Templates226227| File | Purpose |228|------|---------|229| `templates/page.tsx` | Standard async page |230| `templates/layout.tsx` | Layout w/ metadata |231| `templates/action.ts` | 7-step secure Server Action |232| `templates/loading.tsx` | Loading UI skeleton |233| `templates/error.tsx` | Error boundary |234235## Assets236237| File | Purpose |238|------|---------|239| `assets/next.config.ts` | Production config w/ security headers |240| `assets/middleware.ts` | Deny-by-default auth (Next.js 15) |241| `assets/proxy.ts` | Deny-by-default auth (Next.js 16+) |242243## Quick Reference: Senior Code Review244245Before merging any PR, verify:246247**Performance**248- [ ] No unnecessary "use client"249- [ ] Images use next/image with dimensions250- [ ] Heavy components dynamic imported251- [ ] Parallel fetching (Promise.all)252253**Security**254- [ ] Server Actions validate with Zod255- [ ] Auth in actions (not just middleware)256- [ ] IDOR prevention (user owns resource)257- [ ] No secrets in client bundles258259**Architecture**260- [ ] Components in correct layer261- [ ] No cross-feature imports262- [ ] DRY patterns used (createSafeAction)263- [ ] URL state for shareable state264265**Quality**266- [ ] No `any` types267- [ ] Error boundaries present268- [ ] Loading states for async269- [ ] Accessibility (semantic HTML, alt text)270271---272> Converted and distributed by [TomeVault](https://tomevault.io/claim/georgekhananaev) — claim your Tome and manage your conversions.273<!-- tomevault:4.0:skill_md:2026-04-12 -->