Communitygithub.com

nuxt4-patterns

Nuxt 4 앱 패턴: 하이드레이션 안전성, 성능, 라우트 규칙, 지연 로딩 및 useFetch와 useAsyncData를 사용한 SSR 안전 데이터 가져오기. Nuxt 4 앱을 빌드하거나 검토할 때, 또는 하이드레이션 불일치 및 SSR 안전 데이터 가져오기를 디버깅할 때 사용합니다.

nuxt4-patterns란 무엇인가요?

이 스킬은 Nuxt 4 애플리케이션 개발 시 발생하는 주요 문제점인 SSR 하이드레이션 불일치, 라우트 렌더링 전략, 성능 최적화 및 데이터 가져오기 패턴을 해결하기 위한 모범 사례를 제공합니다. 특히, `useFetch`와 `useAsyncData`를 사용한 SSR 안전 데이터 가져오기 방식, `routeRules`를 통한 하이브리드 렌더링(정적 사전 렌더링, SWR, ISR, 클라이언트 전용) 설정 방법, 그리고 `Lazy` 프리픽스와 지연 하이드레이션 컴포넌트를 활용한 코드 분할 및 성능 개선 방법을 중점적으로 다룹니다. Claude Code와 같은 AI 에이전트가 Nuxt 4 프로젝트를 리뷰하거나 디버깅할 때, 정확한 패턴을 적용하여 생산성을 높이고 일반적인 실수를 방지하도록 설계되었습니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/nuxt4-patterns

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

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

문서

Nuxt 4 패턴

SSR, 하이브리드 렌더링, 라우트 규칙 또는 페이지 수준 데이터 가져오기를 사용하는 Nuxt 4 앱을 빌드하거나 디버깅할 때 사용하세요.

활성화 시점

  • 서버 HTML과 클라이언트 상태 간의 하이드레이션 불일치
  • prerender, SWR, ISR 또는 클라이언트 전용 섹션과 같은 라우트 수준 렌더링 결정
  • 지연 로딩, 지연 하이드레이션 또는 페이로드 크기와 관련된 성능 작업
  • useFetch, useAsyncData 또는 $fetch를 사용한 페이지 또는 컴포넌트 데이터 가져오기
  • 라우트 파라미터, 미들웨어 또는 SSR/클라이언트 차이로 인한 Nuxt 라우팅 문제

하이드레이션 안전성

  • 첫 번째 렌더링을 결정론적으로 유지하세요. Date.now(), Math.random(), 브라우저 전용 API 또는 저장소 읽기를 SSR 렌더링 템플릿 상태에 직접 넣지 마세요.
  • 서버가 동일한 마크업을 생성할 수 없는 경우 브라우저 전용 로직을 onMounted(), import.meta.client, ClientOnly 또는 .client.vue 컴포넌트 뒤로 이동하세요.
  • vue-router의 것이 아닌 Nuxt의 useRoute() 컴포저블을 사용하세요.
  • SSR 렌더링 마크업을 구동하기 위해 route.fullPath를 사용하지 마세요. URL 프래그먼트는 클라이언트 전용이므로 하이드레이션 불일치를 만들 수 있습니다.
  • ssr: false를 불일치에 대한 기본 수정 사항이 아닌, 진정한 브라우저 전용 영역을 위한 탈출구로 취급하세요.

데이터 가져오기

  • 페이지 및 컴포넌트에서 SSR 안전 API 읽기를 위해 await useFetch()를 선호하세요. 서버에서 가져온 데이터를 Nuxt 페이로드로 전달하고 하이드레이션 시 두 번째 가져오기를 방지합니다.
  • fetcher가 단순한 $fetch() 호출이 아닌 경우, 사용자 정의 키가 필요한 경우, 또는 여러 비동기 소스를 구성하는 경우 useAsyncData()를 사용하세요.
  • 캐시 재사용 및 예측 가능한 새로 고침 동작을 위해 useAsyncData()에 안정적인 키를 제공하세요.
  • useAsyncData() 핸들러를 부작용이 없도록 유지하세요. SSR 및 하이드레이션 중에 실행될 수 있습니다.
  • 사용자 트리거 쓰기 또는 클라이언트 전용 작업에는 $fetch()를 사용하고, SSR에서 하이드레이션되어야 하는 최상위 페이지 데이터에는 사용하지 마세요.
  • 탐색을 차단해서는 안 되는 중요하지 않은 데이터에는 lazy: true, useLazyFetch() 또는 useLazyAsyncData()를 사용하세요. UI에서 status === 'pending'을 처리하세요.
  • SEO 또는 초기 페인트에 필요하지 않은 데이터에만 server: false를 사용하세요.
  • pick으로 페이로드 크기를 줄이고 깊은 반응성이 필요하지 않은 경우 더 얕은 페이로드를 선호하세요.
const route = useRoute()

const { data: article, status, error, refresh } = await useAsyncData(
  () => `article:${route.params.slug}`,
  () => $fetch(`/api/articles/${route.params.slug}`),
)

const { data: comments } = await useFetch(`/api/articles/${route.params.slug}/comments`, {
  lazy: true,
  server: false,
})

라우트 규칙

렌더링 및 캐싱 전략을 위해 nuxt.config.ts에서 routeRules를 선호하세요:

export default defineNuxtConfig({
  routeRules: {
    '/': { prerender: true },
    '/products/**': { swr: 3600 },
    '/blog/**': { isr: true },
    '/admin/**': { ssr: false },
    '/api/**': { cache: { maxAge: 60 * 60 } },
  },
})
  • prerender: 빌드 시 정적 HTML
  • swr: 캐시된 콘텐츠를 제공하고 백그라운드에서 재검증
  • isr: 지원 플랫폼에서 증분 정적 재생성
  • ssr: false: 클라이언트 렌더링 라우트
  • cache 또는 redirect: Nitro 수준 응답 동작

라우트 규칙을 전역이 아닌 라우트 그룹별로 선택하세요. 마케팅 페이지, 카탈로그, 대시보드 및 API는 일반적으로 서로 다른 전략이 필요합니다.

지연 로딩 및 성능

  • Nuxt는 이미 라우트별로 페이지 코드를 분할합니다. 구성 요소 분할을 미세 최적화하기 전에 라우트 경계를 의미 있게 유지하세요.
  • Lazy 프리픽스를 사용하여 중요하지 않은 구성 요소를 동적으로 가져오세요.
  • UI에서 실제로 필요할 때까지 청크가 로드되지 않도록 v-if와 함께 지연 구성 요소를 조건부로 렌더링하세요.
  • 접히는 영역 아래 또는 중요하지 않은 대화형 UI에 대해 지연 하이드레이션을 사용하세요.
<template>
  <LazyRecommendations v-if="showRecommendations" />
  <LazyProductGallery hydrate-on-visible />
</template>
  • 사용자 정의 전략의 경우 가시성 또는 유휴 전략과 함께 defineLazyHydrationComponent()를 사용하세요.
  • Nuxt 지연 하이드레이션은 단일 파일 구성 요소에서 작동합니다. 지연 하이드레이션된 구성 요소에 새 prop을 전달하면 즉시 하이드레이션이 트리거됩니다.
  • 내부 탐색에는 NuxtLink를 사용하여 Nuxt가 라우트 구성 요소 및 생성된 페이로드를 미리 가져올 수 있도록 하세요.

검토 체크리스트

  • 첫 번째 SSR 렌더링과 하이드레이션된 클라이언트 렌더링이 동일한 마크업을 생성합니다.
  • 페이지 데이터는 최상위 $fetch가 아닌 useFetch 또는 useAsyncData를 사용합니다.
  • 중요하지 않은 데이터는 지연되고 명시적인 로딩 UI가 있습니다.
  • 라우트 규칙이 페이지의 SEO 및 최신성 요구 사항과 일치합니다.
  • 무거운 대화형 섹션은 지연 로드되거나 지연 하이드레이션됩니다.

Individual skills in this repo

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

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

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.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

관련 스킬