Communitygithub.com

ComeOnOliver/skillshub

Next.js App Router 원칙: 서버 컴포넌트, 데이터 페칭, 라우팅 패턴

skillshub란 무엇인가요?

이 스킬은 Next.js App Router 개발의 핵심 원칙과 모범 사례를 종합적으로 안내합니다. 서버 컴포넌트와 클라이언트 컴포넌트의 적절한 사용 기준, 효율적인 데이터 페칭 패턴, 파일 기반 라우팅 조직화 방법, API 라우트 핸들러, 이미지 및 번들 최적화, 정적 및 동적 메타데이터 설정, 계층별 캐싱 전략, 서버 액션의 활용과 주의사항, 그리고 일반적인 안티 패턴을 다룹니다. Claude Code, Cursor, Codex와 같은 AI 에이전트 플랫폼에서 활용 가능하며, 표에 정리된 의사 결정 트리와 Best Practices 표를 통해 개발자가 상황에 맞는 최적의 선택을 할 수 있도록 돕습니다. 기본적으로 서버 컴포넌트를 우선 사용하고, 필요한 경우에만 클라이언트 컴포넌트를 추가하는 원칙을 강조합니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/aiskillstore/marketplace/sickn33/nextjs-best-practices

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

Next.js 모범 사례

Next.js App Router 개발을 위한 원칙.


1. 서버 컴포넌트 vs 클라이언트 컴포넌트

의사 결정 트리

필요한 것이...?
│
├── useState, useEffect, 이벤트 핸들러
│   └── 클라이언트 컴포넌트 ('use client')
│
├── 직접 데이터 페칭, 상호작용 불필요
│   └── 서버 컴포넌트 (기본값)
│
└── 둘 다?
    └── 분할: 서버 부모 + 클라이언트 자식

기본 설정

유형사용처
서버데이터 페칭, 레이아웃, 정적 콘텐츠
클라이언트폼, 버튼, 상호작용 UI

2. 데이터 페칭 패턴

페치 전략

패턴사용처
기본값정적 (빌드 시 캐싱)
RevalidateISR (시간 기반 갱신)
No-store동적 (매 요청마다)

데이터 흐름

출처패턴
데이터베이스서버 컴포넌트 페치
API캐싱과 함께 fetch
사용자 입력클라이언트 상태 + 서버 액션

3. 라우팅 원칙

파일 규칙

파일목적
page.tsx라우트 UI
layout.tsx공유 레이아웃
loading.tsx로딩 상태
error.tsx오류 경계
not-found.tsx404 페이지

라우트 조직

패턴사용처
라우트 그룹 (name)URL 변경 없이 구성
병렬 라우트 @slot동일 레벨의 여러 페이지
인터셉트 (.)모달 오버레이

4. API 라우트

라우트 핸들러

메서드용도
GET데이터 읽기
POST데이터 생성
PUT/PATCH데이터 업데이트
DELETE데이터 삭제

모범 사례

  • Zod로 입력값 검증
  • 적절한 상태 코드 반환
  • 오류를 우아하게 처리
  • 가능하면 Edge 런타임 사용

5. 성능 원칙

이미지 최적화

  • next/image 컴포넌트 사용
  • 접힌 부분 위 우선순위 설정
  • 블러 플레이스홀더 제공
  • 반응형 크기 사용

번들 최적화

  • 무거운 컴포넌트에 동적 임포트 사용
  • 라우트 기반 코드 분할 (자동)
  • 번들 분석기로 분석

6. 메타데이터

정적 vs 동적

유형사용처
정적 내보내기고정 메타데이터
generateMetadata라우트별 동적 메타데이터

필수 태그

  • title (50-60자)
  • description (150-160자)
  • Open Graph 이미지
  • 표준 URL

7. 캐싱 전략

캐시 계층

계층제어
요청fetch 옵션
데이터revalidate/tags
전체 라우트라우트 설정

재검증

방법사용처
시간 기반revalidate: 60
온디맨드revalidatePath/Tag
캐시 없음no-store

8. 서버 액션

사용 사례

  • 폼 제출
  • 데이터 변경
  • 재검증 트리거

모범 사례

  • 'use server'로 표시
  • 모든 입력값 검증
  • 타입화된 응답 반환
  • 오류 처리

9. 안티 패턴

❌ 하지 말 것✅ 할 것
모든 곳에서 'use client' 사용기본적으로 서버 사용
클라이언트 컴포넌트에서 페치서버에서 페치
로딩 상태 건너뛰기loading.tsx 사용
오류 경계 무시error.tsx 사용
큰 클라이언트 번들동적 임포트

10. 프로젝트 구조

app/
├── (marketing)/     # 라우트 그룹
│   └── page.tsx
├── (dashboard)/
│   ├── layout.tsx   # 대시보드 레이아웃
│   └── page.tsx
├── api/
│   └── [resource]/
│       └── route.ts
└── components/
    └── ui/

기억하세요: 서버 컴포넌트는 이유가 있어 기본값입니다. 거기서 시작하고, 필요할 때만 클라이언트를 추가하세요.

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

관련 스킬