nextjs-app-router
Skill31 starsChanged 18 days agoMITView on GitHub
Use when implementing or reviewing a Next.js App Router application with server and client components, route handlers, Proxy migration, caching, authentication, streaming, or deployment. Use react-development for framework-neutral components and api-design-first for external APIs.
- Reads credentials
- Installs packages
14 other projects use a version of this.
Adopted by
Most recently taken up by
- abdullahqureshi27/TaskCortextheir own version, first seen Nov 8, 2026
- geronco/commandvault-librarytheir own version, first seen Oct 13, 2026
- russolutionconsult/claude-skillstheir own version, first seen Oct 11, 2026
- SkillMedev/vercel-platformtheir own version, first seen Oct 5, 2026
- SkillMedev/full-stack-web-devtheir own version, first seen Oct 5, 2026
- sabahattink/antigravity-fullstack-hqtheir own version, first seen Sep 20, 2026
Used with
Projects with it also use skill-creator.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
SentrySkillskill-creator
Create new agent skills following the Agent Skills specification. Use when asked to "create a skill", "add a new skill", "write a skill", "make a skill", "build a skill", or scaffold a new skill with SKILL.md. Guides through requirements, writing, registration, and verification.
Also in 3 projects that use this
Other versions14 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 14
- sabahattink/antigravity-fullstack-hq★ 30same name
- jawwad-ali/claude-code-skills★ 4same name
- HamzaSheikh768/Agents-Skills-Lap★ 3same name
- LeahyCC/claude-skills★ 3same name
- amirrezaalasti/codescribe★ 2same name
- desilokesh1/antigravity-fullstack-hq★ 2same name
- dennisrongo/claude-skills★ 1same name
- geronco/commandvault-library★ 1same name
- SkillMedev/full-stack-web-dev★ 1same name
- SkillMedev/vercel-platform★ 1same name
4 more not listed
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 repository172 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- 00-meta-initializationSkill
- chwezi-dev-engineSkill
- ai-agent-commercial-operationsSkill
- ai-agent-compliance-controlsSkill
- ai-agent-governance-and-limitsSkill
- ai-agent-multi-agent-coordinationSkill
- ai-agent-observability-evaluationSkill
- ai-agent-runtime-architectureSkill
- ai-agent-safety-and-red-teamSkill
- ai-agent-tooling-and-hitlSkill
- ai-analyticsSkill
- ai-app-architectureSkill
- ai-cost-and-meteringSkill
- ai-economic-value-engineSkill
- ai-evaluationSkill
- ai-feature-rollout-and-experimentationSkill
- ai-feature-specSkill
- ai-incident-responseSkill
- ai-llm-integrationSkill
- ai-model-gatewaySkill
- ai-observability-and-debuggingSkill
- ai-opportunity-canvasSkill
- ai-prompt-engineeringSkill
- ai-rag-patternsSkill
- ai-securitySkill
- ai-web-appsSkill
- coding-agent-optimizationSkill
- openai-agents-sdkSkill
- android-developmentSkill
- api-design-firstSkill
- distributed-systems-patternsSkill
- ecommerce-platform-audit-requirementsSkill
- graphql-patternsSkill
- microservices-architectureSkill
- system-architecture-designSkill
- validation-contractSkill
- database-design-engineeringSkill
- database-reliabilitySkill
- mysql-engineeringSkill
- postgresql-engineeringSkill
- cicd-pipelinesSkill
- cloud-architectureSkill
- deployment-release-engineeringSkill
- docker-developmentSkill
- infrastructure-as-codeSkill
- kubernetes-platformSkill
- observability-monitoringSkill
- reliability-engineeringSkill
- execution-plan-scriptsSkill
- accounting-engineSkill
- accounting-finance-controllerSkill
- electronic-fiscal-taxingSkill
- multicurrency-and-fxSkill
- avalonia-desktop-developmentSkill
- frontend-architectureSkill
- frontend-performanceSkill
- image-compressionSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
10 rules. 0 are common, 3 are distinctive, and 7 are very specific to this project.
0
Common
Most of the 12 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 32
Use the links and companion skills already referenced in this file when deeper context is needed.
- Distinctive: line 173
Treat each Server Action as a public endpoint: authenticate, authorize, validate, mutate, then revalidate only the affected path or tag.
- Very specific: line 364
Do NOT 'use client' every component — server by default
- Very specific: line 365
Do NOT use getServerSideProps/getStaticProps in App Router
- Very specific: line 366
Do NOT store secrets in NEXT_PUBLIC_ vars
- Very specific: line 367
Do NOT useEffect for data — fetch in server components
- Distinctive: line 368
Do NOT create separate Express servers — use Route Handlers
- Very specific: line 369
Do NOT await fetches sequentially — use Promise.all
- Very specific: line 370
Do NOT skip loading.tsx — every dynamic route needs a Suspense boundary
- Very specific: line 387
Read and search the application first.
“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Next.js App Router Patterns
Acknowledgement: Shared by Peter Bamuhigire, techguypeter.com, +256 784 464178.
<!-- dual-compat-start -->Chwezi Product Excellence Standard (mandatory)
Any Chwezi app or system UI work (effective 01 Nov 2026) MUST follow the Chwezi Product Excellence Standard in chwezi-design-engine (resolve via the engine-routing table; never hard-code the path): doctrine/product-excellence-standard.md and skill skills/00-cross-cutting-ops-qa-a11y/chwezi-product-excellence-standard. Engineering gates: product-excellence-engineering-gates.md. Authorise every page, Route Handler and Server Action on the server (PX-GATE-04), keep queued and confirmed states distinct, and meet Core Web Vitals at p75 on a low-end mobile profile. Where this skill and the standard differ, the standard wins.
Use When
- Next.js App Router patterns for production — server/client components, parallel routes, Proxy migration, server-side authorization, caching, background jobs (BullMQ), data fetching, authentication, deployment, and CI/CD.
Evidence Produced
| Category | Artifact | Format | Example |
| Correctness | Route + middleware test plan | Markdown doc covering server/client component boundaries, parallel routes, and middleware | docs/web/nextjs-route-tests.md |
| Security | RBAC three-tier configuration note | Markdown doc covering middleware / server action / data-access guards | docs/web/nextjs-rbac.md |
References
- Use the links and companion skills already referenced in this file when deeper context is needed.
- For private tenant-owned data and auth/cache boundaries, load
references/tenant-data-security.md.
<!-- dual-compat-end -->Project Setup
npx create-next-app@latest my-app \
--typescript --tailwind --eslint --app --src-dirFolder Structure (App Router)
app/
├── layout.tsx # Root layout (required)
├── page.tsx # Home route /
├── (marketing)/ # Route group — no URL segment
├── @notifications/ # Parallel route slot
│ └── page.tsx
├── dashboard/
│ ├── layout.tsx # Nested layout
│ ├── page.tsx
│ ├── loading.tsx # Suspense fallback
│ ├── error.tsx # Error boundary ('use client')
│ └── not-found.tsx
└── api/users/route.ts # GET/POST /api/usersServer vs Client Components
// Server component (default) — async, zero JS to client
// Public, non-sensitive example only. For user-specific data, authenticate at
// the data-access boundary and avoid shared/static caching; see the tenant
// data security reference below.
export default async function UsersPage() {
const users = await fetch('https://api.example.com/users', {
cache: 'force-cache', // static
// next: { revalidate: 60 } // ISR
// cache: 'no-store' // SSR
}).then(r => r.json());
return <ul>{users.map(u => <li key={u.id}>{u.name}</li>)}</ul>;
}
// Client component — needs interactivity, browser APIs
'use client';
export default function Counter() {
const [count, setCount] = useState(0);
return <button onClick={() => setCount(c => c + 1)}>Count: {count}</button>;
}Rule: Push 'use client' as far down the tree as possible.
Routing
| File | Route |
app/page.tsx | / |
app/blog/[slug]/page.tsx | /blog/:slug |
app/shop/[...slug]/page.tsx | /shop/* catch-all |
app/(auth)/login/page.tsx | /login (route group) |
app/@modal/page.tsx | Parallel slot |
Dynamic Routes + generateStaticParams
export default async function BlogPost({ params }: { params: Promise<{ slug: string }> }) {
const { slug } = await params;
const post = await fetchPost(slug);
return <article><h1>{post.title}</h1></article>;
}
export async function generateStaticParams() {
const posts = await fetchAllPosts();
return posts.map(p => ({ slug: p.slug }));
}Parallel Routes (@slot)
// app/support/layout.tsx — load @tickets and @chat independently
export default function SupportLayout({ tickets, chat }: {
tickets: React.ReactNode; chat: React.ReactNode;
}) {
return (
<div className="grid grid-cols-2 gap-4">
<aside>{tickets}</aside>
<main>{chat}</main>
</div>
);
}
// Directories: app/support/@tickets/page.tsx app/support/@chat/page.tsx
// Use case: dashboards, live feeds, multi-pane UIs loading at different speedsData Fetching
ISR Revalidation Guidelines
| Content Type | Revalidate | Pattern |
| Blog / docs | 60s | next: { revalidate: 60 } |
| News feed | 10s | next: { revalidate: 10 } |
| Products / pricing | 300s | next: { revalidate: 300 } |
| Static marketing | 86400s | cache: 'force-cache' |
| User-specific | Dynamic | cache: 'no-store' |
| Real-time (stock) | N/A | SSR or WebSocket |
Parallel Fetch + React cache()
// Parallel fetching
const [user, posts] = await Promise.all([
fetch('/api/user').then(r => r.json()),
fetch('/api/posts').then(r => r.json()),
]);
// Deduplication for POST/GraphQL requests
import { cache } from 'react';
export const getUser = cache(async (id: string) => db.user.findUnique({ where: { id } }));Route Handlers (API Routes)
Route Handlers are public entry points. Authenticate and authorize in the
data-access function on every request; never return an unscoped table scan. See
references/tenant-data-security.md for the complete read-only example.
Server Actions
Treat each Server Action as a public endpoint: authenticate, authorize, validate, mutate, then revalidate only the affected path or tag. Do not rely on a hidden UI control or page-level check for authorization.
Server Actions vs API Routes
| Use | When |
| Server Action | Form submissions, mutations from UI, same-app data changes |
| API Route | Public APIs, webhooks, third-party consumers, complex error handling |
Proxy and request routing
// proxy.ts — project root. A redirect is only a navigation aid.
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
export function proxy(request: NextRequest) {
const { pathname } = request.nextUrl;
const hasSessionCookie = Boolean(request.cookies.get('session')?.value);
if (!hasSessionCookie && pathname.startsWith('/dashboard')) {
return NextResponse.redirect(new URL('/login', request.url));
}
return NextResponse.next();
}
export const config = { matcher: ['/dashboard/:path*', '/api/:path*'] };Authorization and tenant data access
Proxy may perform an optimistic redirect from the presence of a session cookie.
It must not trust a role cookie, establish tenant membership, or replace a
server-side authorization check. Verify the session and permission in a
server-only data-access layer for each page, Route Handler, and Server Action.
Apply the verified tenant predicate in the database query and return an
allowlisted DTO. See `references/tenant-data-security.md` for a complete
read-only invoice path and negative cases.Redis Caching
// lib/redis.ts
import Redis from 'ioredis';
const redis = new Redis(process.env.REDIS_URL!);
export default redis;
User-specific results must not use a shared cache key or a shared static
render. Establish authorization before reading data. If a cache is introduced,
prove key isolation, invalidation, expiry, and failure behaviour for the
verified tenant and permission context; otherwise keep the path uncached and
private. Cache invalidation is not an authorization control.Background Jobs (BullMQ)
// lib/queue.ts
import { Queue, Worker } from 'bullmq';
import Redis from 'ioredis';
const connection = new Redis(process.env.REDIS_URL!);
export const emailQueue = new Queue('email', { connection });
// Worker (separate process or dedicated route)
new Worker('email', async (job) => {
const { to, subject, body } = job.data;
await sendEmail(to, subject, body);
}, { connection });
// Enqueue from API route
export async function POST(req: NextRequest) {
const { email } = await req.json();
await emailQueue.add('welcome', { to: email, subject: 'Welcome!' });
return Response.json({ queued: true });
}Authentication (NextAuth v5)
// auth.ts
export const { handlers, signIn, signOut, auth } = NextAuth({
providers: [GitHub({ clientId: process.env.GITHUB_ID!, clientSecret: process.env.GITHUB_SECRET! })],
callbacks: {
jwt({ token, user }) { if (user) token.role = user.role; return token; },
session({ session, token }) { session.user.role = token.role as string; return session; },
},
});Database (Prisma Singleton)
// lib/prisma.ts — prevents connection exhaustion in dev HMR
import { PrismaClient } from '@prisma/client';
const globalForPrisma = globalThis as unknown as { prisma: PrismaClient };
export const db = globalForPrisma.prisma || new PrismaClient({ log: ['query'] });
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = db;Database Selection
| Database | Use When |
| PostgreSQL + Prisma | Relational data, transactions, production default |
| MongoDB + Mongoose | Document/flexible schemas, content management |
| Firebase Firestore | Real-time sync, serverless, mobile-first |
CI/CD (GitHub Actions)
name: CI/CD
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with: { node-version: '24.x' }
- run: npm ci
- run: npm run lint
- run: npm test
- run: npm run build
deploy:
needs: build
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- run: npm install -g vercel && vercel --prod --token=${{ secrets.VERCEL_TOKEN }}Deployment
| Platform | Best For |
| Vercel | Zero-config, global CDN, Edge Network, native Next.js |
| Railway | Simple self-hosted, easy DB provisioning |
| AWS Amplify | Full AWS ecosystem, enterprise |
| Docker/Self-hosted | Full control, no vendor lock-in |
# next.config.js: module.exports = { output: 'standalone' }
FROM node:20-alpine AS runner
WORKDIR /app
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
CMD ["node", "server.js"]Built-in Components
import Image from 'next/image';
import Link from 'next/link';
<Image src="/hero.jpg" alt="Hero" width={800} height={600} priority />
<Link href="/dashboard">Dashboard</Link>
<Link href={`/blog/${slug}`} prefetch={false}>Post</Link>Anti-Patterns
- Do NOT
'use client'every component — server by default - Do NOT use
getServerSideProps/getStaticPropsin App Router - Do NOT store secrets in
NEXT_PUBLIC_vars - Do NOT
useEffectfor data — fetch in server components - Do NOT create separate Express servers — use Route Handlers
- Do NOT await fetches sequentially — use
Promise.all - Do NOT skip
loading.tsx— every dynamic route needs a Suspense boundary
Sources: Rambert — Advanced Next.js for Everyone (2024); Kim — The Next.js Handbook (2023); Jain — Modern Web Applications with Next.js (2024); Krause — The Complete Developer (2024)
Decision rules
| Condition | Choice | Failure avoided |
| No browser API or interaction is needed | Keep a Server Component | Unnecessary client JavaScript |
| Independent data blocks a route | Fetch concurrently and stream non-critical regions | Sequential latency |
| Mutation is application-internal | Use a validated, authorised Server Action | Duplicate transport plumbing |
| Contract serves external consumers | Use a Route Handler with an explicit contract | Hidden coupling |
Capability contract
Read and search the application first. Edit only when authorised; execute the existing type-check, tests, build, and route smoke checks when available. Network access is optional for current Next.js documentation.
Inputs
| Artefact | Required? | Purpose |
| Next.js version, route requirements, data/cache boundaries, auth, and deployment target | yes | Select App Router patterns |
Outputs
- Produce Next.js implementation or design with route, cache, error, test, and deployment evidence.
Degraded mode
Fallback without a runnable Next.js environment: provide route/cache contracts and mark runtime rendering and invalidation unverified.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
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.

