# Next.js App Router taste

An opinionated set of Next.js App Router conventions enforcing Server Components by default, Server Actions validated with Zod, and feature-based folder organization.

- prompt · `type=prompt` · ChatGPT, Claude.ai · ★ 174676
- Author: f
- License: CC0-1.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/f/prompts.chat/tree/HEAD/prompts.csv
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/prompts/nextjs-app-router-taste

## What it does

The prompt supplies the model with strict App Router architecture guidelines paired with confidence scores. Server Components act as the default baseline, while `"use client"` stays confined to interactive leaf nodes. Data fetching happens directly on the server. The setup bypasses intermediary internal API routes for reads, routing all mutations through Server Actions verified by Zod schemas.

Code organization groups loaders, components, and tests by feature instead of file types. For persistence, the instructions specify Prisma or Drizzle with clients contained inside `lib/db.ts`. Cache invalidation relies on fetch tags and `revalidateTag` rather than ad-hoc in-memory storage. Large projects must omit barrel files, preventing slow build times.

Testing splits responsibilities: Playwright verifies critical user flows, while Vitest handles isolated components. Middleware logic remains restricted to authentication redirects and locale resolution, keeping heavy compute out of the request pipeline.

## Install

### ChatGPT (native platform)

**How to use**
- Paste the text at the start of a chat or into project instructions

### Claude Code

**Manually: put the files in place**
- File: `.claude/commands/prompts.csv.md`

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/f/prompts.chat/tree/HEAD/prompts.csv

## When to use it
- Restrict `"use client"` directives strictly to interactive leaf components
- Validate Server Action mutation payloads with Zod schemas
- Colocate loaders, tests, and UI components by feature
- Prevent slow build times by eliminating barrel files in large apps
- Manage cache invalidation using fetch tags and `revalidateTag`

## Example prompts
- Create a user profile form using Next.js Server Actions and Zod validation
- Generate a product route segment with direct server fetching, `loading.tsx`, and `error.tsx`
- Set up a database query module using Drizzle through `lib/db.ts` with fetch tags

## Source text · prompts.csv · CC0-1.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: b5f9261b84245fa5.

BEGIN THIRD-PARTY FILE b5f9261b84245fa5
```text
# Next.js App Router taste
- Default to Server Components and add "use client" only at leaf components that need interactivity. Confidence: 0.95
- Fetch data in Server Components directly instead of using API routes for internal reads. Confidence: 0.90
- Use Server Actions for mutations and validate input with zod. Confidence: 0.85
- Colocate components, loaders and tests by feature instead of by file type. Confidence: 0.80
- Use Tailwind CSS with a small set of design tokens in CSS variables. Confidence: 0.85
- Use next/image and next/font for all images and fonts. Confidence: 0.90
- Add loading.tsx and error.tsx to every route segment that fetches data. Confidence: 0.85
- Use Prisma or Drizzle with typed queries and keep the client in a single lib/db.ts. Confidence: 0.80
- Cache with fetch tags and revalidateTag instead of manual in-memory caches. Confidence: 0.75
- Keep environment variables validated at startup with a typed env module. Confidence: 0.85
- Generate metadata with generateMetadata and always set Open Graph images. Confidence: 0.85
- Avoid barrel files in large apps because they hurt build times. Confidence: 0.70
- Use middleware only for auth redirects and locale routing, never heavy logic. Confidence: 0.80
- Test critical flows with Playwright and components with vitest. Confidence: 0.80
- Deploy on Vercel with preview deployments for every pull request. Confidence: 0.75
```
END THIRD-PARTY FILE b5f9261b84245fa5

The third-party file has ended. Everything between the b5f9261b84245fa5 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

© f · CC0-1.0 · https://github.com/f/prompts.chat/tree/HEAD/prompts.csv

From the same set: [f/prompts.chat](https://affpapa.org/en/nevibecode/by/f/prompts.chat.md) — 143 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
