본문으로 건너뛰기
Skillpedia
웹사이트 및 UI (프런트엔드)48k · #5301

nextjs-best-practices

하는 일

이 가이드는 웹사이트와 웹 애플리케이션을 만드는 프레임워크인 Next.js를 모범 사례에 따라 사용하는 방법을 가르칩니다. 코드를 서버와 브라우저에 나누는 방법, 데이터를 가져오는 방법, 페이지를 구성하는 방법을 설명합니다.

사용하는 경우

  • ✓새 Next.js 프로젝트를 시작할 때.
  • ✓성능을 높이기 위해 기존 프로젝트를 리팩터링할 때.
  • ✓서버 컴포넌트와 클라이언트 컴포넌트에 대해 배우는 경우.

스킬 링크

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/nextjs-best-practices/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/nextjs-best-practices/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“Next.js 프로젝트에서 페이지를 어떻게 구성할 수 있나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

Next.js는 작업을 서버(페이지가 만들어지는 곳)와 브라우저(사용자가 상호작용하는 곳) 사이에 나눕니다. 파일 규칙과 특정 패턴을 사용해 속도와 사용자 경험을 최적화합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

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 child

By 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.

When to Use

This skill is applicable to execute the workflow or actions described in the overview.

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
자주 묻는 질문

서버 컴포넌트와 클라이언트 컴포넌트는 무엇인가요?

서버 컴포넌트는 서버에서 실행되며 데이터를 가져오는 데 적합합니다. 클라이언트 컴포넌트는 브라우저에서 실행되며 버튼이나 양식 같은 상호작용에 사용됩니다.

Next.js는 데이터를 어떻게 가져오나요?

필요에 따라 정적으로(빌드 시점에), 주기적으로 갱신하며, 또는 모든 요청마다 데이터를 가져올 수 있습니다.

‘서버 액션’이란 무엇인가요?

양식 제출이나 데이터 업데이트 같은 작업을 서버에서 안전하고 효율적으로 실행하는 함수입니다.

상세 정보

작성자의 원본 설명

Next.js App Router principles. Server Components, data fetching, routing patterns.

repo: sickn33/agentic-awesome-skills

인기도

GitHub 스타
48k
순위
#5301
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬