Communitygithub.com

ComeOnOliver/skillshub

Next.js 애플리케이션에서 URL, 클라이언트, 글로벌 상태를 관리하기 위한 모범 사례를 제공합니다. URL 상태 관리, 클라이언트 훅, 전역 상태 관리 시 사용합니다.

skillshub란 무엇인가요?

이 스킬은 Next.js 애플리케이션에서 상태 관리를 위한 포괄적인 가이드를 제공합니다. URL을 공유 가능하고 영속적인 상태의 단일 진실 공급원(Single Source of Truth)으로 사용하는 URL 주도 상태 관리, SWR 또는 TanStack Query를 활용한 서버 상태 관리, Zustand 또는 Jotai를 사용한 클라이언트 상태 관리 등 세 가지 주요 상태 유형을 다룹니다. 또한 상태 끌어올리기(Lifting State), Next.js 15+에서의 통합, hydration 오류 방지와 같은 고급 주제도 다룹니다. 반패턴(Anti-Patterns) 섹션에서는 단순한 상태에 전역 저장소를 사용하지 않거나, 상태에 큰 객체를 넣지 않거나, 데이터 페칭에 useEffect를 사용하지 않는 등 피해야 할 일반적인 실수를 명확히 제시합니다. 이 스킬은 Cursor, Claude Code, Codex와 같은 AI 에이전트에서 hooks/*.ts, store.ts, components/*.tsx 파일과 useState, useContext, Zustand, Redux 같은 패턴이 감지될 때 자동으로 트리거되어 개발자가 일관되고 성능 좋은 상태 관리 코드를 작성하도록 돕습니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/HoangNguyen0403/agent-skills-standard/nextjs-state-management

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

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

문서

상태 관리

우선순위: P2 (중간)

구현 가이드라인

  • URL 상태: 공유 가능하거나 영속적인 상태에는 URL을 단일 진실 공급원(Single Source of Truth)으로 사용하세요. URL 매개변수는 새로고침과 링크 간에 공유 가능합니다. useSearchParams()로 접근하고 useRouter()로 업데이트합니다. 패턴: const params = new URLSearchParams(searchParams); params.set('q', term); useRouter().replace(...) .
  • 서버 상태: 서버 데이터 캐싱 및 페칭에는 SWR 또는 TanStack Query (React Query) 를 사용하세요. 서버 데이터를 수동으로 useState에 동기화하지 마세요.
  • 클라이언트 상태: Zustand (create<CartState>()((set) => ({ ... }))) — 'use client' 컴포넌트에서만 사용 — 또는 복잡하고 빈도가 높은 UI 상태에는 Jotai를 사용하세요. 낮은 빈도의 데이터에만 Context API를 활용하여 Prop Drilling을 피하세요.
  • 상태 끌어올리기: 상태를 컴포넌트에 최대한 가깝게 배치하세요. 상태가 형제 간에 공유될 때만 부모로 끌어올리세요.
  • Next.js 15+ 통합: 클라이언트 컴포넌트의 상태 업데이트가 서버 사이드 렌더링 로직과 충돌하지 않도록 하세요. 낙관적 업데이트(optimistic updates) 는 useOptimistic 훅을 사용하여 관리하세요.
  • 상태 수화(Hydration): 클라이언트 컴포넌트에서 localStorage로 상태를 초기화할 때 Hydration 오류를 방지하기 위해 주의하세요. useEffect로 감싸거나 mounted 플래그를 사용하세요.

2. URL-주도 상태 (검색/필터)

useSearchParams + useRouter를 사용하여 URL 매개변수를 업데이트하세요. URL 상태 패턴을 참조하세요.

3. 서버 상태 (TanStack Query / SWR)

클라이언트에서 "실시간" 데이터가 필요한 경우(예: 주식 가격 폴링, 채팅), 수동으로 useEffect로 fetch를 구현하지 마세요. 라이브러리를 사용하세요.

// 자동 캐싱, 중복 제거, 재검증(refreshInterval 사용)
const { data, error } = useSWR('/api/user', fetcher, {
  refreshInterval: 30000,
});

라이브러리 패턴

특정 상태 관리 패턴에 대해서는 다음을 참조하세요:

반패턴(Anti-Patterns)

  • 단순한 상태에 전역 저장소 사용 금지: useState나 URL 매개변수를 사용하세요. 기본 UI에 Zustand를 사용하지 마세요.
  • 상태에 큰 객체 사용 금지: 세분화된 기본 타입으로 분해하여 불필요한 리렌더링을 방지하세요.
  • 데이터 페칭에 useEffect 사용 금지: 서버 상태에는 SWR 또는 TanStack Query를 사용하세요.
  • 클라이언트 저장소에 서버 상태 저장 금지: RSC에서 데이터를 가져오고, 클라이언트 저장소는 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

관련 스킬