Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)18k · #10692

nextjs-expert

Skill này làm gì

Skill này hướng dẫn xây dựng ứng dụng web với Next.js, gồm App Router, server component, lấy dữ liệu, cache và triển khai. Nó dành cho nhà phát triển xây dựng trang web và ứng dụng web nhanh, thân thiện với công cụ tìm kiếm.

Khi nào nên dùng

  • ✓Khi bạn bắt đầu một ứng dụng Next.js mới hoặc chuyển một ứng dụng sang App Router.
  • ✓Khi một trang tải chậm và bạn muốn giảm JavaScript phía client.
  • ✓Khi bạn cần API route hoặc middleware trong một dự án Next.js.

Liên kết skill

https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/nextjs-expert/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/nextjs-expert/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Thiết lập một trang App Router của Next.js tải dữ liệu sản phẩm ở server và hiển thị trạng thái đang tải khi nó lấy dữ liệu.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill khuyên dùng server component theo mặc định, route theo thư mục, các ranh giới loading và error, và route handler, với lựa chọn render tĩnh hoặc theo yêu cầu.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Next.js Expert

A seasoned Next.js architect with deep expertise in the App Router paradigm, server-side rendering strategies, and production deployment patterns. This skill provides guidance on building performant, SEO-friendly web applications using Next.js 14+ conventions, including Server Components, Streaming, and the full spectrum of data fetching and caching mechanisms.

Key Principles

  • Prefer Server Components by default; only add "use client" when the component requires browser APIs, event handlers, or React state
  • Leverage the app/ directory structure where each folder segment maps to a URL route, using layout.tsx for shared UI and page.tsx for unique content
  • Design data fetching at the server layer using async Server Components and fetch with Next.js caching semantics
  • Use generateStaticParams for static pre-rendering of dynamic routes at build time, falling back to on-demand ISR for long-tail pages
  • Keep client bundles small by pushing logic into Server Components and using dynamic imports for heavy client-only libraries

Techniques

  • Structure routes with app/[segment]/page.tsx, using route groups (parentheses) to organize without affecting URL paths
  • Implement loading.tsx and error.tsx boundaries at each route segment to provide instant loading states and graceful error recovery
  • Use Route Handlers (app/api/.../route.ts) with exported GET, POST, PUT, DELETE functions for API endpoints
  • Configure middleware in middleware.ts at the project root with a matcher config to intercept requests for auth, redirects, or header injection
  • Optimize images with next/image (automatic srcSet, lazy loading, AVIF/WebP) and fonts with next/font (zero layout shift, self-hosted subsets)
  • Enable ISR by returning revalidate values from fetch calls or using revalidatePath/revalidateTag for on-demand cache invalidation
  • Set up next.config.js with redirects, rewrites, headers, and the experimental options appropriate to your deployment target

Common Patterns

  • Parallel Routes: Use @named slots in layouts to render multiple page-level components simultaneously, enabling dashboards and split views
  • Intercepting Routes: Place (..) convention routes to show modals on navigation while preserving the direct URL as a full page
  • Server Actions: Define async functions with "use server" for form submissions and mutations without building separate API routes
  • Streaming with Suspense: Wrap slow data-fetching components in Suspense boundaries to stream HTML progressively and improve TTFB

Pitfalls to Avoid

  • Do not use useEffect for data fetching in Server Components; fetch directly in the component body or use server-side utilities
  • Do not place "use client" at the layout level unless every child truly requires client interactivity, as this opts out the entire subtree from server rendering
  • Do not confuse the Pages Router (pages/ directory) patterns with App Router conventions; they have different data fetching and routing models
  • Do not skip setting proper cache headers and revalidation times, as stale data and unnecessary re-renders degrade both performance and user experience
Câu hỏi thường gặp

Server component là gì?

Đó là component chạy trên server, nên có thể lấy dữ liệu mà không gửi thêm code xuống trình duyệt.

Khi nào nên thêm use client?

Chỉ khi component cần tính năng trình duyệt, event handler hoặc state của React, như skill khuyên.

loading.tsx và error.tsx làm gì?

Chúng hiển thị trạng thái đang tải khi một route đang tải và một thông báo thân thiện nếu có lỗi.

Chi tiết

Mô tả gốc của tác giả

Next.js expert for App Router, SSR/SSG, API routes, middleware, and deployment

repo: RightNow-AI/openfang

Độ phổ biến

Sao GitHub
18k
Vị trí xếp hạng
#10692
Giấy phép
Apache-2.0
Cập nhật
2/7/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự