Communitygithub.com

ComeOnOliver/skillshub

檔案系統路由、佈局與路由群組。在實作 Next.js App Router 時,用於嵌套佈局或路由群組。(觸發條件:app/**/page.tsx、app/**/layout.tsx、app/**/loading.tsx、App Router、Layout、Route Group、parallel routes)

skillshub 是什麼?

此技能為 Next.js App Router 路由實作提供 P0 優先級的關鍵指引,涵蓋檔案系統路由、佈局與路由群組的核心模式。它明確要求使用 `app/` 目錄結構,並透過 `layout.tsx` 實現共享 UI 的自動嵌套,同時利用 `loading.tsx`、`error.tsx` 與 `not-found.tsx` 處理各種狀態。技能強調使用路由群組(如 `(auth)`)將功能組織成不影響 URL 路徑的區塊,動態路由則使用 `[slug]` 並搭配 `generateStaticParams` 定義靜態路徑。此外,還支援平行路由(`@modal`)與攔截路由(`(.)route`)等進階佈局模式,確保開發者能建構出高效、可維護的頁面結構。在資料與函式方面,技能強制要求對 Next.js 15+ 的 `params: Promise`、`searchParams`、`cookies()` 與 `headers()` 進行 `await`,並透過 `middleware.ts` 執行邊緣端驗證與重新導向。預設使用 React Server Components(RSC),僅在葉節點使用 `'use client'` 以處理互動性。錯誤邊界透過 `loading.tsx` 自動包裹 Suspense,而 `error.tsx` 則必須是 Client Component 並提供 `reset` 函式。反模式方面,技能明確禁止未 await 的非同步 API、在樹根使用 `'use client'`、在嵌套佈局中放置 `<html>`/`<body>` 標籤,以及遺漏 `error.tsx`,確保路由實作的穩定性與安全性。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/HoangNguyen0403/agent-skills-standard/nextjs-app-router

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

優先級:P0(關鍵)

實作指南

路由架構

  • 結構:使用 app/ 目錄。透過 app/dashboard/layout.tsx 定義路由,並回傳 {children};共享 UI 會自動嵌套在 app/layout.tsx 中。使用 loading.tsx、error.tsx 與 not-found.tsx 處理各狀態。
  • 區段:使用路由群組(括號 (auth))組織功能,使其不影響 URL 路徑。使用動態路由(括號 [slug])並透過 generateStaticParams 定義靜態路徑。
  • 特殊路由:使用平行路由(@modal),將插槽加入父佈局並提供 default.tsx 作為備用。使用攔截路由((.)route)實現儀表板等進階佈局。

資料與函式

  • Next.js 15+ 非同步:務必 await params: Promise、searchParams、cookies() 與 headers()。
  • 安全性:使用 middleware.ts 進行邊緣端驗證與重新導向。確保所有**路由處理器(route.ts)**都已加入適當的驗證檢查。
  • RSC:預設使用 React Server Components(RSC)。僅在葉節點使用 'use client' 以處理互動性(鉤子/事件)。
  • 錯誤邊界:建立 app/dashboard/loading.tsx 自動將路由包裹在 Suspense 邊界中。在 error.tsx 中,使用 'use client' 並提供 reset: () => void 函式。
const theme = cookieStore.get('theme');

檔案慣例

  • page.tsx:路由的 UI。
  • layout.tsx:包裝子元件的共享 UI。在導航時保持持久。
  • loading.tsx:用於載入狀態的 Suspense 邊界。
  • error.tsx:錯誤邊界(必須是 Client Component)。
  • route.ts:伺服器端 API 端點。

結構模式

  • 路由群組:使用括號 (auth) 組織,不影響 URL 路徑。
  • 私有資料夾:使用底線 _lib 排除在路由之外。
  • 動態路由:使用括號 [slug] 或 [...slug](捕獲所有)。

最佳實踐

  • RSC 邊界:確保傳遞給 Client Component 的 props 是可序列化的。請參閱 RSC 邊界與序列化。
  • 平行路由(@folder):在同一佈局中渲染多個頁面。使用 default.tsx 作為備用。
  • 攔截路由((..)folder):在當前佈局上下文中載入路由。
  • 同地放置:將元件檔案、樣式和測試保留在路由資料夾內。
  • 佈局:使用根佈局(app/layout.tsx)放置 <html> 和 <body> 標籤。
  • 自託管標準

反模式

  • 不要未 await 非同步 API:params、cookies()、headers() 在 Next.js 15+ 中是 Promise;務必 await。
  • 不要在樹根使用 'use client':將它放在葉節點;保持佈局和頁面為 Server Components。
  • 不要在嵌套佈局中使用 <html>/<body>:只有 app/layout.tsx(根佈局)應包含它們。
  • 不要遺漏 error.tsx:每個路由區段都需要一個 Client Component 錯誤邊界。

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

相關技能