react-server-components-framework

SKILL开发
开发 未标注权限 许可证不明确

Design and implement React Server Components with Next.js 15 App Router. Master server-first architecture, streaming SSR, Server Actions, React 19 patterns, and modern data fetching for 2025+ development.

一句话选型结论

按资料字段整理

react-server-components-framework是开发类的 Agent Skill,安装方式:GitHub 仓库,权限级别未标注,许可证不明确,没有现成安装命令,需按说明手动放置 SKILL.md。技能本质是给模型读的说明书,效果取决于模型与客户端;装完先用一个小任务验证,再放进正式流程。

分类开发 安装方式GitHub 仓库 权限级别未标注权限 许可证许可证不明确
累计安装 未标注 本周 未标注
GitHub 星标 3 仓库 create-yg-app
下载量 未标注 技能市场下载数
权限级别 未标注权限 安装前请确认风险范围
许可证 许可证不明确 未说明

安装

GitHub 仓库
在支持 Skills 的客户端里执行,装完问一句「你有哪些技能」验证
  1. 1
    确认客户端支持

    确认你的客户端支持 Skills(Claude、Codex、Cursor 等),并升级到较新的版本。

  2. 2
    拿到技能文件

    按安装说明或仓库 README,把 SKILL.md 放到客户端的 skills 目录(一般一个技能一个文件夹)。

  3. 3
    刷新技能列表

    重新打开客户端,或刷新技能列表,让新放进来的技能被加载。

  4. 4
    验证是否生效

    问一句「你有哪些技能」,确认列表里出现它,再拿一个小任务试跑。

技能档案

开发
字段来自技能仓库与公开索引,中文说明由本站标注
作者 / 维护方yonatangross仓库 create-yg-app · 版本 未标注
宿主客户端未标注技能可被这些客户端加载
安装方式GitHub 仓库安装包 yonatangross/create-yg-app
权限级别未标注权限安装前请确认风险范围
许可证未说明许可证不明确,商用前请自行确认条款
仓库可用性available技能仓库当前是否可访问
最近核验未标注上游最后核验时间 · 数据更新 未标注
正文体量15.6 KBSKILL.md 原文大小,越大说明说明书写得越细

典型使用场景

3 类
按分类整理的常见用法,具体以 SKILL.md 为准
写代码与改 bug

按需求补代码、定位并修掉报错。

读仓库与生成改动

让模型读懂项目结构,再给出可落地的改动。

跑测试与排查故障

按现象排查问题,补测试用例并复跑。

选择建议

装之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 基础信息齐全,可以先按说明装一个试试。

先想清楚的地方

  • 没有标注权限级别,实际能做什么要装好后确认。
  • 许可证不明确,商用或二次分发前先到仓库确认条款。
  • 没有现成安装命令,要按安装说明或仓库 README 手动放置。
  • 没有做站内核验,内容以作者仓库为准。
  • 技能只是说明书,实际效果取决于模型与客户端,装完先用小任务试一遍。

更适合

  • 需要在开发场景里给模型补一套做法的人。
  • 愿意先读一遍 SKILL.md、确认它会让模型做什么的人。

不太适合

  • 对许可证要求很严、必须明确可商用的人。
  • 只想装完就自动变强、不打算看说明书的人。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
技能权限级别安装方式累计安装宿主客户端安装命令
react-server-components-framework当前 未标注权限 GitHub 仓库 未标注 未标注 无
技能审查员 浏览器控制 ClawHub 市场 877.9 万 OpenClaw 有
Vercel React 最佳实践 浏览器控制 GitHub 仓库 849.1 万 Codex、Claude、Cursor 有
GitHub 代码协作 联网访问 ClawHub 市场 763.3 万 OpenClaw 有
网页设计指南 联网访问 GitHub 仓库 668.6 万 Codex、Claude、Cursor 有
本体论 只读 ClawHub 市场 663.7 万 OpenClaw 有

SKILL.md 全文

15.6 KB
模型实际读到的说明书原文,来自技能仓库

React Server Components Framework

Overview

React Server Components (RSC) represent a paradigm shift in React architecture, enabling server-first rendering with client-side interactivity. This skill provides comprehensive patterns, templates, and best practices for building modern Next.js 15 applications using the App Router with Server Components, Server Actions, and streaming.

When to use this skill:
- Building Next.js 15+ applications with the App Router
- Designing component boundaries (Server vs Client Components)
- Implementing data fetching with caching and revalidation
- Creating mutations with Server Actions
- Optimizing performance with streaming and Suspense
- Implementing Partial Prerendering (PPR)
- Designing advanced routing patterns (parallel, intercepting routes)


Why React Server Components Matter

RSC fundamentally changes how we think about React applications:

  • Server-First Architecture: Components render on the server by default, reducing client bundle size
  • Zero Client Bundle: Server Components don't ship JavaScript to the client
  • Direct Backend Access: Access databases, file systems, and APIs directly from components
  • Automatic Code Splitting: Only Client Components and their dependencies are bundled
  • Streaming & Suspense: Progressive rendering for instant perceived performance
  • Type-Safe Data Fetching: End-to-end TypeScript from database to UI
  • SEO & Performance: Server rendering improves Core Web Vitals and SEO

Core Concepts

1. Server Components vs Client Components

Server Components (default):
- Can be async and use await
- Direct database access
- Cannot use hooks or browser APIs
- Zero client JavaScript

Client Components (with 'use client'):
- Can use hooks (useState, useEffect, etc.)
- Browser APIs available
- Cannot be async
- Ships JavaScript to client

Key Rule: Server Components can render Client Components, but Client Components cannot directly import Server Components (use children prop instead).

Detailed Patterns: See references/component-patterns.md for:
- Complete component boundary rules
- Composition patterns
- Props passing strategies
- Common pitfalls and solutions

2. Data Fetching

Next.js extends the fetch API with powerful caching and revalidation:

// Static (cached indefinitely)
await fetch(url, { cache: 'force-cache' })

// Revalidate every 60 seconds
await fetch(url, { next: { revalidate: 60 } })

// Always fresh
await fetch(url, { cache: 'no-store' })

// Tag-based revalidation
await fetch(url, { next: { tags: ['posts'] } })

Patterns:
- Parallel fetching: Promise.all([fetch1, fetch2, fetch3])
- Sequential fetching: When data depends on previous results
- Route segment config: Control static/dynamic rendering

Detailed Implementation: See references/data-fetching.md for:
- Complete caching strategies
- Revalidation methods (revalidatePath, revalidateTag)
- Database queries in Server Components
- generateStaticParams for SSG
- Error handling patterns

3. Server Actions

Server Actions enable mutations without API routes:

// app/actions.ts
'use server'

export async function createPost(formData: FormData) {
  const title = formData.get('title') as string
  const post = await db.post.create({ data: { title } })

  revalidatePath('/posts')
  redirect(`/posts/${post.id}`)
}

Progressive Enhancement: Forms work without JavaScript, then enhance with client-side states.

Detailed Implementation: See references/server-actions.md for:
- Progressive enhancement patterns
- useFormStatus and useActionState hooks (React 19)
- Optimistic UI with useOptimistic + useTransition
- Validation with Zod
- Inline vs exported Server Actions

4. Streaming with Suspense

Stream components independently for better perceived performance:

import { Suspense } from 'react'

export default function Dashboard() {
  return (
    <div>
      <Suspense fallback={<ChartSkeleton />}>
        <RevenueChart />
      </Suspense>

      <Suspense fallback={<InvoicesSkeleton />}>
        <LatestInvoices />
      </Suspense>
    </div>
  )
}

Benefits:
- Show content as it's ready
- Non-blocking data fetching
- Better Core Web Vitals

Templates: Use templates/ServerComponent.tsx for streaming patterns

5. Advanced Routing

Parallel Routes: Render multiple pages simultaneously

app/
  @team/page.tsx
  @analytics/page.tsx
  layout.tsx  # Receives both as props

Intercepting Routes: Show modals while preserving URLs

app/
  photos/[id]/page.tsx      # Direct route
  (..)photos/[id]/page.tsx  # Intercepted (modal)

Partial Prerendering (PPR): Mix static and dynamic content

export const experimental_ppr = true

// Static shell + dynamic Suspense boundaries

Detailed Implementation: See references/routing-patterns.md for:
- Parallel routes layout implementation
- Intercepting routes for modals
- PPR configuration and patterns
- Route groups for organization
- Dynamic, catch-all, and optional catch-all routes


Searching References

Use grep to find specific patterns in references:

# Find component patterns
grep -r "Server Component" references/

# Search for data fetching strategies
grep -A 10 "Caching Strategies" references/data-fetching.md

# Find Server Actions examples
grep -B 5 "Progressive Enhancement" references/server-actions.md

# Locate routing patterns
grep -n "Parallel Routes" references/routing-patterns.md

# Search migration guide
grep -i "pages router\|getServerSideProps" references/migration-guide.md

React 19 Patterns (2025+)

React 19 introduces significant changes to component patterns. This section covers the modernization requirements.

Detailed Implementation: See references/react-19-patterns.md for:
- Complete migration guide from React 18
- Code transformation examples
- Testing patterns for React 19 hooks

1. Function Declarations over React.FC

React 19 deprecates React.FC because it no longer includes children in props by default. Always use function declarations:

// ❌ DEPRECATED (React 18 pattern)
export const Button: React.FC<ButtonProps> = ({ children, onClick }) => {
  return <button onClick={onClick}>{children}</button>
}

// ✅ RECOMMENDED (React 19 pattern)
export function Button({ children, onClick }: ButtonProps): React.ReactNode {
  return <button onClick={onClick}>{children}</button>
}

// ✅ ALSO VALID (arrow function without React.FC)
export const Button = ({ children, onClick }: ButtonProps): React.ReactNode => {
  return <button onClick={onClick}>{children}</button>
}

Benefits:
- Simpler type inference
- Explicit children in props when needed
- Better tree-shaking
- Clearer component signatures

2. Ref as Prop (Removal of forwardRef)

React 19 removes the need for forwardRef. Refs are now passed as regular props:

// ❌ DEPRECATED (React 18 pattern)
import { forwardRef } from 'react'

const Input = forwardRef<HTMLInputElement, InputProps>((props, ref) => {
  return <input ref={ref} {...props} />
})

// ✅ RECOMMENDED (React 19 pattern)
interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
  ref?: React.Ref<HTMLInputElement>
}

export function Input({ ref, ...props }: InputProps): React.ReactNode {
  return <input ref={ref} {...props} />
}

Note: For backwards compatibility during migration, you can support both patterns temporarily.

3. useActionState (replaces useFormState)

useActionState is the new API for form state management:

'use client'

import { useActionState } from 'react'

interface FormState {
  message: string
  success: boolean
}

async function submitForm(prevState: FormState, formData: FormData): Promise<FormState> {
  const email = formData.get('email')
  // Process form...
  return { message: 'Submitted!', success: true }
}

export function ContactForm(): React.ReactNode {
  const [state, formAction, isPending] = useActionState(submitForm, {
    message: '',
    success: false
  })

  return (
    <form action={formAction}>
      <input name="email" type="email" disabled={isPending} />
      <SubmitButton />
      {state.message && <p>{state.message}</p>}
    </form>
  )
}

4. useFormStatus for Submit Buttons

'use client'

import { useFormStatus } from 'react-dom'

export function SubmitButton(): React.ReactNode {
  const { pending } = useFormStatus()

  return (
    <button type="submit" disabled={pending} aria-busy={pending}>
      {pending ? 'Submitting...' : 'Submit'}
    </button>
  )
}

5. useOptimistic for Optimistic Updates

'use client'

import { useOptimistic, useTransition } from 'react'

interface Item { id: string; name: string }

export function ItemList({ items }: { items: Item[] }): React.ReactNode {
  const [optimisticItems, addOptimisticItem] = useOptimistic(
    items,
    (state, newItem: Item) => [...state, newItem]
  )
  const [, startTransition] = useTransition()

  const handleAdd = async (item: Item) => {
    startTransition(() => {
      addOptimisticItem(item) // Immediate UI update
    })
    await saveItem(item) // Server mutation (auto-rollback on error)
  }

  return <ul>{optimisticItems.map(i => <li key={i.id}>{i.name}</li>)}</ul>
}

Best Practices

Component Boundary Design

  • ✅ Keep Client Components at the edges (leaves) of the component tree
  • ✅ Use Server Components by default
  • ✅ Extract minimal interactive parts to Client Components
  • ✅ Pass Server Components as children to Client Components
  • ❌ Avoid making entire pages Client Components

Data Fetching

  • ✅ Fetch data in Server Components close to where it's used
  • ✅ Use parallel fetching for independent data
  • ✅ Set appropriate cache and revalidate options
  • ✅ Use generateStaticParams for static routes
  • ❌ Don't fetch data in Client Components with useEffect (use Server Components)

Performance

  • ✅ Use Suspense boundaries for streaming
  • ✅ Implement loading.tsx for instant loading states
  • ✅ Enable PPR for static/dynamic mix
  • ✅ Optimize images with next/image
  • ✅ Use route segment config to control rendering mode

Error Handling

  • ✅ Implement error.tsx for error boundaries
  • ✅ Use not-found.tsx for 404 pages
  • ✅ Handle fetch errors gracefully
  • ✅ Validate Server Action inputs

Templates

Use provided templates for common patterns:

  • templates/ServerComponent.tsx - Basic async Server Component with data fetching
  • templates/ClientComponent.tsx - Interactive Client Component with hooks
  • templates/ServerAction.tsx - Server Action with validation and revalidation

Examples

Complete Blog App

See examples/blog-app/ for a full implementation:
- Server Components for post listing and details
- Client Components for comments and likes
- Server Actions for creating/editing posts
- Streaming with Suspense
- Parallel routes for dashboard


Checklists

RSC Implementation Checklist

See checklists/rsc-implementation.md for comprehensive validation covering:
- [ ] Component boundaries properly defined (Server vs Client)
- [ ] Data fetching with appropriate caching strategy
- [ ] Server Actions for mutations
- [ ] Streaming with Suspense for slow components
- [ ] Error handling (error.tsx, not-found.tsx)
- [ ] Loading states (loading.tsx)
- [ ] Metadata API for SEO
- [ ] Route segment config optimized


Common Patterns

Search with URL State

// app/search/page.tsx
export default async function SearchPage({
  searchParams,
}: {
  searchParams: { q?: string }
}) {
  const query = searchParams.q || ''
  const results = query ? await searchProducts(query) : []

  return (
    <div>
      <SearchForm initialQuery={query} />
      <SearchResults results={results} />
    </div>
  )
}

Authentication

import { cookies } from 'next/headers'

export default async function DashboardPage() {
  const token = cookies().get('token')?.value
  const user = await verifyToken(token)

  if (!user) {
    redirect('/login')
  }

  return <Dashboard user={user} />
}

Optimistic UI

'use client'

import { useOptimistic } from 'react'

export function TodoList({ todos }) {
  const [optimisticTodos, addOptimisticTodo] = useOptimistic(
    todos,
    (state, newTodo) => [...state, newTodo]
  )

  return <ul>{/* render optimisticTodos */}</ul>
}

Migration from Pages Router

Incremental Adoption: Both pages/ and app/ can coexist

Key Changes:
- getServerSideProps → async Server Component
- getStaticProps → async Server Component with caching
- API routes → Server Actions
- _app.tsx → layout.tsx
- <Head> → generateMetadata function

Detailed Migration: See references/migration-guide.md for:
- Step-by-step migration guide
- Before/after code examples
- Common migration pitfalls
- Layout and metadata migration patterns


Troubleshooting

Error: "You're importing a component that needs useState"
- Fix: Add 'use client' directive to the component

Error: "async/await is not valid in non-async Server Components"
- Fix: Add async to function declaration

Error: "Cannot use Server Component inside Client Component"
- Fix: Pass Server Component as children prop instead of importing

Error: "Hydration mismatch"
- Fix: Use 'use client' for components using Date.now(), Math.random(), or browser APIs


Resources

  • Next.js 15 Documentation
  • React Server Components RFC
  • App Router Migration Guide
  • Server Actions Documentation

Skill Metadata

Skill Version: 1.4.0
Last Updated: 2025-12-29
Maintained by: AI Agent Hub Team

Changelog

v1.4.0 (2025-12-29)

  • Updated blog-app-example.tsx to e-commerce dashboard (Product + Order management)
  • All examples now use real-world dashboard/app scenarios
  • Updated React 19 patterns with concrete e-commerce types (OrderStatus, Product, etc.)
  • Added exhaustive type checking examples with OrderStatus enum
  • Updated all "SkillForge" and "project" references to real application examples
  • Examples demonstrate: Product catalog, Inventory tracking, Order history, SEO optimization

v1.3.0 (2025-12-27)

  • Updated to React 19.2.3 patterns
  • Added complete React 19 modernization guide
  • Updated all examples to use function declarations (no React.FC)
  • Updated to useActionState (replaced useFormState)

v1.2.0 (2025-12-20)

  • Added TanStack Router patterns for SPAs
  • Added React 19 hooks (use(), useOptimistic, useActionState)
  • Added promise caching patterns for use() hook

v1.1.0 (2025-12-15)

  • Added comprehensive RSC implementation patterns
  • Added Server Actions with progressive enhancement
  • Added streaming with Suspense examples

Next Steps

After mastering React Server Components:
1. Explore Streaming API Patterns skill for real-time data
2. Use Type Safety & Validation skill for tRPC integration
3. Apply Edge Computing Patterns skill for global deployment
4. Reference Performance Optimization skill for Core Web Vitals

常见问题

5 问
答案由本站依据条目字段整理
react-server-components-framework怎么安装?

没有现成安装命令:按安装说明或仓库 README,把 SKILL.md 放进客户端的 skills 目录(一般一个技能一个文件夹)。

react-server-components-framework支持哪些客户端?

资料没有标注宿主客户端,但只要客户端支持 Skills(Claude、Codex、Cursor 等),一般都能加载。

react-server-components-framework权限高吗,安全吗?

权限级别为未标注权限。安装前先看它会读取或写入哪些内容。

react-server-components-framework收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于技能本身和所用的模型或客户端,正式使用前按作者说明确认。

react-server-components-framework用什么许可证?

许可证标注为 未说明(许可证不明确)。商用或二次分发前请到仓库确认条款原文。

热门专题

按场景挑技能
全部专题 →

技能内容以作者仓库为准;分类、权限级别与许可证状态的中文说明为中文整理,最近核验 未标注。