
Nextjs Best Practices
- 595 installs
- 29.9k repo stars
- Updated July 27, 2026
- davila7/claude-code-templates
nextjs-best-practices is a Claude Code skill that ensures Next.js App Router decisions follow official patterns for Server Components, data fetching, and file-based routing during development.
About
Next.js Best Practices is an agent skill that embeds official App Router principles directly into your Claude, Cursor or Codex workflow. It provides decision trees, pattern tables, and concrete rules for when to use Server Components versus Client Components, which data fetching strategy to apply, and how to structure routes and layouts. The skill gives developers immediate, context-aware guidance on caching behavior, component splitting, file conventions, and data flow so that every file created follows current Next.js recommendations without needing to leave the editor or consult external docs. It is especially valuable for solo builders who want to ship production-grade Next.js applications without accumulating anti-patterns around rendering, performance, or routing organization.
- Decision tree for choosing Server vs Client Components with clear interactivity rules
- 3 data fetching patterns: static (default), ISR with revalidate, and dynamic no-store
- Complete file convention reference covering page.tsx, layout.tsx, loading.tsx, error.tsx and not-found.tsx
- Route organization patterns including route groups (name) and parallel routes @slot
- Server-first data flow guidance for databases, APIs, and user input
Nextjs Best Practices by the numbers
- 595 all-time installs (skills.sh)
- +10 installs in the week ending Jun 27, 2026 (Skillselion tracking)
- Ranked #564 of 2,277 Frontend Development skills by installs in the Skillselion catalog
- Security screen: LOW risk (skills.sh audit)
- Data as of Jul 28, 2026 (Skillselion catalog sync)
npx skills add https://github.com/davila7/claude-code-templates --skill nextjs-best-practicesAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 595 |
|---|---|
| repo stars | ★ 29.9k |
| Security audit | 3 / 3 scanners passed |
| Last updated | July 27, 2026 |
| Repository | davila7/claude-code-templates ↗ |
When should Next.js components be Server vs Client?
Ensure every Next.js App Router decision follows official patterns for Server Components, data fetching, and file-based routing.
Who is it for?
Frontend developers building or reviewing Next.js App Router apps who want consistent Server Component and routing decisions.
Skip if: Pages Router legacy codebases or teams not using Next.js App Router file-based routing and React Server Components.
When should I use this skill?
The user implements Next.js routes, debates Server vs Client components, or asks for App Router data fetching and layout patterns.
What you get
App Router files with correct Server or Client boundaries, routing layout, and data-fetching patterns per Next.js guidance.
- Component boundary decisions
- App Router route and layout structure
Files
Next.js Best Practices
Principles for Next.js App Router development.
---
1. Server vs Client Components
Decision Tree
Does it need...?
│
├── useState, useEffect, event handlers
│ └── Client Component ('use client')
│
├── Direct data fetching, no interactivity
│ └── Server Component (default)
│
└── Both?
└── Split: Server parent + Client childBy Default
| Type | Use |
|---|---|
| Server | Data fetching, layout, static content |
| Client | Forms, buttons, interactive UI |
---
2. Data Fetching Patterns
Fetch Strategy
| Pattern | Use |
|---|---|
| Default | Static (cached at build) |
| Revalidate | ISR (time-based refresh) |
| No-store | Dynamic (every request) |
Data Flow
| Source | Pattern |
|---|---|
| Database | Server Component fetch |
| API | fetch with caching |
| User input | Client state + server action |
---
3. Routing Principles
File Conventions
| File | Purpose |
|---|---|
page.tsx | Route UI |
layout.tsx | Shared layout |
loading.tsx | Loading state |
error.tsx | Error boundary |
not-found.tsx | 404 page |
Route Organization
| Pattern | Use |
|---|---|
Route groups (name) | Organize without URL |
Parallel routes @slot | Multiple same-level pages |
Intercepting (.) | Modal overlays |
---
4. API Routes
Route Handlers
| Method | Use |
|---|---|
| GET | Read data |
| POST | Create data |
| PUT/PATCH | Update data |
| DELETE | Remove data |
Best Practices
- Validate input with Zod
- Return proper status codes
- Handle errors gracefully
- Use Edge runtime when possible
---
5. Performance Principles
Image Optimization
- Use next/image component
- Set priority for above-fold
- Provide blur placeholder
- Use responsive sizes
Bundle Optimization
- Dynamic imports for heavy components
- Route-based code splitting (automatic)
- Analyze with bundle analyzer
---
6. Metadata
Static vs Dynamic
| Type | Use |
|---|---|
| Static export | Fixed metadata |
| generateMetadata | Dynamic per-route |
Essential Tags
- title (50-60 chars)
- description (150-160 chars)
- Open Graph images
- Canonical URL
---
7. Caching Strategy
Cache Layers
| Layer | Control |
|---|---|
| Request | fetch options |
| Data | revalidate/tags |
| Full route | route config |
Revalidation
| Method | Use |
|---|---|
| Time-based | revalidate: 60 |
| On-demand | revalidatePath/Tag |
| No cache | no-store |
---
8. Server Actions
Use Cases
- Form submissions
- Data mutations
- Revalidation triggers
Best Practices
- Mark with 'use server'
- Validate all inputs
- Return typed responses
- Handle errors
---
9. Anti-Patterns
| ❌ Don't | ✅ Do |
|---|---|
| 'use client' everywhere | Server by default |
| Fetch in client components | Fetch in server |
| Skip loading states | Use loading.tsx |
| Ignore error boundaries | Use error.tsx |
| Large client bundles | Dynamic imports |
---
10. Project Structure
app/
├── (marketing)/ # Route group
│ └── page.tsx
├── (dashboard)/
│ ├── layout.tsx # Dashboard layout
│ └── page.tsx
├── api/
│ └── [resource]/
│ └── route.ts
└── components/
└── ui/---
Remember: Server Components are the default for a reason. Start there, add client only when needed.
Related skills
Forks & variants (1)
Nextjs Best Practices has 1 known copy in the catalog totaling 2 installs. They canonicalize to this original listing.
- xenitv1 - 2 installs
How it compares
Use nextjs-best-practices for App Router architecture guardrails rather than generic React component advice.
FAQ
What does nextjs-best-practices decide first?
nextjs-best-practices starts with a Server versus Client Component decision tree checking for useState, useEffect, event handlers, and data-fetching needs before assigning App Router component boundaries.
Which Next.js router does nextjs-best-practices target?
nextjs-best-practices targets the Next.js App Router with file-based routing, Server Components as the default, and Client Components marked with the use client directive for interactive UI.
Is Nextjs Best Practices safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.