nextjs-patterns
Skill4 starsChanged 3 months agoMITView on GitHub
Next.js frontend conventions: App Router structure, a single lib/api.ts client with namespaced calls, trailing-slash endpoints, dayjs dates, and component/state patterns for frontend-centric and SSR modes. Apply when writing or reviewing Next.js/React UI code.
4 other projects use a version of this.
Adopted by
Most recently taken up by
- theyoungastronauts/waypoint-mdword for word, first seen Jul 8, 2026
- tranhieutt/software_development_departmenttheir own version, first seen Apr 30, 2026
- Nadav011/apex-skillstheir own version, first seen Apr 22, 2026
- peopleforrester/claude-dotfilestheir own version, first seen Apr 5, 2026
Other versions4 projects use a version of this.
Word for word · 1
- theyoungastronauts/waypoint-md★ 0100% same
Edited · 0
None found.
Wrote their own version · 3
- tranhieutt/software_development_department★ 71same name
- peopleforrester/claude-dotfiles★ 3same name
- Nadav011/apex-skills★ 0same 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 repository53 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- actionableSkill
- astro-bootstrapSkill
- astro-patternsSkill
- autopilotSkill
- axon-code-intelSkill
- brainstormingSkill
- commit-conventionsSkill
- cross-repo-contextSkill
- django-bootstrapSkill
- django-patternsSkill
- executeSkill
- find-sessionSkill
- flutter-bootstrapSkill
- flutter-patternsSkill
- full-featureSkill
- intelSkill
- nextjs-bootstrapSkill
- nextjs-fullstack-bootstrapSkill
- nextjs-fullstack-patternsSkill
- nextjs-mui-bootstrapSkill
- nextjs-shadcn-bootstrapSkill
- orchestratorSkill
- phase-breakdownSkill
- plan-and-scopeSkill
- prdSkill
- reactSkill
- recallSkill
- reflectSkill
- relaySkill
- rememberSkill
- scaffoldSkill
- scratchSkill
- tailwindSkill
- ux-specSkill
- ux-to-promptsSkill
- verify-astroSkill
- verify-djangoSkill
- verify-flutterSkill
- verify-nextjs-fullstackSkill
- verify-nextjs-muiSkill
- verify-nextjs-shadcnSkill
- verify-nextjsSkill
- verifySkill
- visual-feedbackSkill
- work-disciplineSkill
- worktreesSkill
- wrapSkill
- write-as-friendSkill
- write-as-humanSkill
- writing-clearlySkill
- writing-skillsSkill
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 1 is distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Use App Router (src/app/ directory) with @/* path alias
- Very specific: line 16
All API types in a single types/api.ts — split only if it exceeds ~800 lines
- Very specific: line 17
All API functions in a single lib/api.ts organized into namespaced objects
- Very specific: line 22
Use import type { ... } for type-only imports
- Distinctive: line 23
Always handle loading, empty, and error states on every page
- Very specific: line 50
All commands run via make (Docker Compose under the hood) — never run npm directly on the host
- Very specific: line 51
Use the matching bootstrap command (/nextjs-bootstrap, /nextjs-mui-bootstrap, or /nextjs-shadcn-bootstrap) when setting up a new project …
- Very specific: line 66
Use /nextjs-bootstrap with frontend-centric mode to scaffold
- Very specific: line 71
Default to Server Components.
- Very specific: line 77
Use /nextjs-bootstrap with SSR-centric mode to scaffold
≈ “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
Skill: Next.js Patterns
Purpose
Guide Claude Code when implementing Next.js features. Projects use one of two modes — check the project's CLAUDE.md or ask.
Project Structure
- Use App Router (
src/app/directory) with@/*path alias - Components organized by feature (
components/goals/,components/settings/), not by type - Shared UI components in
components/ui/with barrelindex.tsexports - Custom hooks in
lib/hooks/with barrelindex.tsexports - All API types in a single
types/api.ts— split only if it exceeds ~800 lines - All API functions in a single
lib/api.tsorganized into namespaced objects
Components
- PascalCase filenames matching the component name, default exports
- Props interface defined above the component, suffixed with
Props - Use
import type { ... }for type-only imports - Always handle loading, empty, and error states on every page
API Client
- Single
lib/api.tswith genericapiFetch<T>base function - Namespaced exports per domain:
authApi,itemsApi, etc. ApiErrorclass withstatus,message,datafields- Trailing slashes on all endpoints (Django REST Framework convention)
- UUIDs as primary identifiers in URLs
Styling
- Semantic color tokens from your UI library — never hardcoded hex in components
- Responsive-first — mobile breakpoints before desktop
Types
interfacefor object shapes,typefor unions/aliases- String literal unions for status fields (not enums)
- Separate
CreateRequest/UpdateRequesttypes (update fields optional) - Dates from backend are
string(ISO 8601) — parse withdayjs
Naming
- Components: PascalCase files + default exports
- Hooks: camelCase with
useprefix, named exports - API namespaces: camelCase with
Apisuffix (itemsApi) - Constants:
UPPER_SNAKE_CASE - Directories: kebab-case for routes, camelCase for lib
Development Environment
- All commands run via
make(Docker Compose under the hood) — never runnpmdirectly on the host - Use the matching bootstrap command (
/nextjs-bootstrap,/nextjs-mui-bootstrap, or/nextjs-shadcn-bootstrap) when setting up a new project from scratch - Hot reload works inside Docker via
WATCHPACK_POLLING=true node_moduleslives inside the container (anonymous volume) — do not install on host
Frontend-Centric Mode
SPA-like architecture, decoupled from backend. Most components are interactive.
- Most components use
'use client'— client-first approach - Data fetching:
useEffect+useState(no React Query/SWR) - State: React Context for global (auth/user),
useStatefor local — no Redux/Zustand - Auth: JWT via localStorage (
lib/auth.ts),UserContext+useUser()hook,useRequireAuth()guard,router.replacefor redirects — no Next.js middleware- Tradeoff: localStorage tokens are readable by any injected script, so an XSS bug leaks the refresh token (and thus long-lived access). Acceptable for a decoupled SPA with disciplined output-escaping/CSP. If you need to survive XSS, store the refresh token in an httpOnly, Secure, SameSite cookie the JS can't read (refresh via a backend route) and keep only the short-lived access token in memory.
- Errors: try/catch with
ApiErrorinstanceof check +react-hot-toast, alwaysfinallyfor loading state - Use
/nextjs-bootstrapwith frontend-centric mode to scaffold
SSR-Centric Mode
Server-rendered, leveraging Next.js built-in features.
- Default to Server Components;
'use client'only for interactivity, hooks, browser APIs - Data fetching: Server Components fetch directly; client components use React Query/SWR
- State: React Query for server state, Context or Zustand for complex UI state
- Auth: Next.js middleware or server-side session checks
- Errors:
error.tsxboundaries at route level,loading.tsx/ Suspense for loading states - Testing: React Testing Library, MSW for API mocking, Playwright for E2E
- Use
/nextjs-bootstrapwith SSR-centric mode to scaffold
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.

