Skip to content
Skills Library
Programming · Learning & explanation

react-server-components

/react-server-components

Use this skill when the user says 'React Server Components', 'RSC', 'use client', 'use server', 'server functions', 'server actions', 'RSC payload', 'client boundary', 'serializable props'. It explains the RSC model in React 19 (framework-agnostic), where to place client boundaries, what can cross the boundary, and how Server Functions mutate data. Do NOT use for: Next.js routing/caching specifics (use nextjs-server-components or react-nextjs), Next.js build internals (use nextjs-internals), or classic SSR hydration tuning (use frontend-rendering-strategies).

Licence
MIT
Last repository change
10.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 10.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Use this skill when the user says 'React Server Components', 'RSC', 'use client', 'use server', 'server functions', 'server actions', 'RSC payload', 'client boundary', 'serializable props'. It explains the RSC model in React 19 (framework-agnostic), where to place client boundaries, what can cross the boundary, and how Server Functions mutate data. Do NOT use for: Next.js routing/caching specifics (use nextjs-server-components or react-nextjs), Next.js build internals (use nextjs-internals), or classic SSR hydration tuning (use frontend-rendering-strategies).

Triggers from the description

React Server ComponentsRSCuse clientuse serverserver functionsserver actionsRSC payloadclient boundary
Original author description

Use this skill when the user says 'React Server Components', 'RSC', 'use client', 'use server', 'server functions', 'server actions', 'RSC payload', 'client boundary', 'serializable props'. It explains the RSC model in React 19 (framework-agnostic), where to place client boundaries, what can cross the boundary, and how Server Functions mutate data. Do NOT use for: Next.js routing/caching specifics (use nextjs-server-components or react-nextjs), Next.js build internals (use nextjs-internals), or classic SSR hydration tuning (use frontend-rendering-strategies).

How it works

  1. Purpose
  2. Agent Protocol
  3. Mental Model
  4. What Can Cross the Server → Client Boundary
  5. Composition Pattern: Server Children Inside Client Wrappers
  6. Streaming a Promise to the Client
  7. Server Functions (Mutations)
  8. Security Rules
  9. Anti-patterns
  10. Architecture Map
Original SKILL.md headings · 193 lines, 1,085 words
SKILL.md preview
---
name: react-server-components
description: >
  Use this skill when the user says 'React Server Components', 'RSC', 'use client', 'use server', 'server functions', 'server actions', 'RSC payload', 'client boundary', 'serializable props'. It explains the RSC model in React 19 (framework-agnostic), where to place client boundaries, what can cross the boundary, and how Server Functions mutate data. Do NOT use for: Next.js routing/caching specifics (use nextjs-server-components or react-nextjs), Next.js build internals (use nextjs-internals), or classic SSR hydration tuning (use frontend-rendering-strategies).
version: "2.0.0"
author: "j4flmao"
license: "MIT"
tags: [frontend, react, rsc, server-components, server-functions, react-19]
---

# React Server Components (RSC)

## Purpose
Server Components are a stable part of React 19: components that render ahead of time on the server (per request or at build time) and whose code never ships to the browser. They are used through a framework or bundler integration (Next.js App Router, React Router v7 RSC support, Parcel/Vite RSC plugins, Waku). This skill gives the correct mental model, boundary placement rules and Server Function usage.

## Agent Protocol

### Trigger
"RSC", "server components", "'use client'", "'use server'", "server action", "server function", "client boundary", "props must be serializable".

### Input Context
- Framework/bundler providing RSC (Next.js, React Router, Waku, Parcel, custom).
- Which parts need interactivity, browser APIs or state.
- Data sources (DB, internal APIs) and auth model.

### Output Artifact
Component tree with boundaries marked, plus code for server/client components and Server Functions.

### Response Format
```
Tree: {Component (server|client)} nested
Boundary: {file with 'use client'} reason: {state|effect|event|browser API}
Data: {where fetched} -> {props passed}
Mutations: {Server Function name} -> {revalidation/refresh}
```

## Mental Model
- **Server Components (default)**: run only on the server, can be `async`, can read DBs/files/secrets, cannot use state, effects, event handlers or browser APIs. Output is serialized into the **RSC payload** (a streamed, React-specific format, not HTML).
- **Client Components**: modules marked with `'use client'` at the top. They are rendered to HTML during SSR *and* hydrated in the browser. Everything they import becomes client code.
- **SSR is separate**: RSC decides *which code runs where*; SSR turns the result (server output + client components) into initial HTML. A framework typically does both.
- `'use client'` marks a **module boundary**, not a single component. Place it on the smallest leaf modules that need interactivity.
- `'use server'` marks **Server Functions** (callable from the client via a network request), not Server Components. There is no `'use server'` directive for components.

## What Can Cross the Server → Client Boundary
Props passed from a Server Component to a Client Component must be serializable by React:
- Allowed: primitives, `bigint`, plain objects/arrays, `Date`, `Map`, `Set`, typed arrays, `Promise` (unwrap with `use()` in the client), JSX elements (including Server Components as `children`), Server Functions.
- Not allowed: class instances, regular functions/closures, Symbols not registered globally, DB connection objects.

## Composition Pattern: Server Children Inside Client Wrappers

```tsx
// Tabs.tsx — client leaf
'use client';
import { useState, type ReactNode } from 'react';

export function Tabs({ labels, children }: { labels: string[]; children: ReactNode[] }) {
  const [active, setActive] = useState(0);
  return (
    <div>
      <div role="tablist">
        {labels.map((label, i) => (
          <button key={label} role="tab" aria-selected={i === active} onClick={() => setActive(i)}>
            {label}
          </button>
        ))}
      </div>
      <div role="tabpanel">{children[active]}</div>
    </div>
  );
}
```
```tsx
// ProductPage.tsx — server component (no directive)
import { Tabs } from './Tabs';
import { db } from './db';

export default async function ProductPage({ id }: { id: string }) {
  const product = await db.product.findUniqueOrThrow({ where: { id } });
  return (
    <Tabs labels={['Details', 'Reviews']}>
      {[<Details key="d" product={product} />, <Reviews key="r" productId={id} />]}
    </Tabs>
  );
}

async function Reviews({ productId }: { productId: string }) {
  const reviews = await db.review.findMany({ where: { productId } });
  return <ul>{reviews.map(r => <li key={r.id}>{r.body}</li>)}</ul>;
}

function Details({ product }: { product: { name: string; description: string } }) {
  return <section><h1>{product.name}</h1><p>{product.description}</p></section>;
}
```
`Reviews` stays a Server Component even though it renders inside a Client Component, because it is passed as already-rendered `children`.

## Streaming a Promise to the Client

```tsx
// server
import { Suspense } from 'react';
import { Comments } from './Comments';
export default function Post({ id }: { id: string }) {
  const commentsPromise = getComments(id); // not awaited: starts work, streams later
  return (
    <Suspense fallback={<p>Loading comments…</p>}>
      <Comments commentsPromise={commentsPromise} />
    </Suspense>
  );
}
```
```tsx
// Comments.tsx
'use client';
import { use } from 'react';
export function Comments({ commentsPromise }: { commentsPromise: Promise<{ id: string; text: string }[]> }) {
  const comments = use(commentsPromise);
  return <ul>{comments.map(c => <li key={c.id}>{c.text}</li>)}</ul>;
}
```

## Server Functions (Mutations)

```ts
// actions.ts
'use server';
import { z } from 'zod';

const Input = z.object({ productId: z.string().min(1), body: z.string().min(1).max(2000) });

export async function addReview(prev: { error?: string }, formData: FormData): Promise<{ error?: string }> {
  const session = await getSession();             // authenticate EVERY call
  if (!session) return { error: 'Not signed in' };
  const parsed = Input.safeParse(Object.fromEntries(formData));
  if (!parsed.success) return { error: 'Invalid review' };
  await db.review.create({ data: { ...parsed.data, userId: session.userId } });
  return {};
}
```
```tsx
'use client';
import { useActionState } from 'react';
import { addReview } from './actions';

export function ReviewForm({ productId }: { productId: string }) {
  const [state, formAction, pending] = useActionState(addReview, {});
  return (
    <form action={formAction}>
      <input type="hidden" name="productId" value={productId} />
      <textarea name="body" required />
      <button disabled={pending}>Post</button>
      {state.error && <p role="alert">{state.error}</p>}
    </form>
  );
}
```
Server Functions are public HTTP endpoints: validate input, check authorization, and never trust hidden fields.

## Security Rules
- Keep secrets in server-only modules; import `server-only` in them so a client import fails the build.
- Never pass whole DB rows to Client Components; select only needed fields (they are visible in the payload).
- Treat every Server Function argument as untrusted input.

## Anti-patterns
| Anti-pattern | Fix |
|--------------|-----|
| `'use client'` at the top of a layout/page | Push it down to interactive leaves |
| Fetching in `useEffect` data the server already has | Fetch in the Server Component, pass props |
| Passing callbacks from server to client | Pass a Server Function or move logic to the client |
| Importing server code (DB client) into a client module | `server-only` package, separate modules |
| Sequential awaits causing waterfalls | Start promises in parallel, `Promise.all`, or stream with Suspense |
| Treating `'use server'` as "this component is server" | It only marks callable functions |

## Architecture Map

```mermaid
flowchart TD
    subgraph Server
        SC["Server Components (async, DB access)"]
        SF["Server Functions ('use server')"]
        P["RSC payload stream"]
    end
    subgraph Browser
        R["React runtime"]
        CC["Client Components ('use client')"]
        DOM["DOM"]
    end
    SC --> P
    P -->|stream| R
    R --> CC
    R --> DOM
    CC -->|form action / call| SF
    SF -->|updated payload| R
```

## Checklist
- [ ] Client boundaries only on leaves that need state/effects/events/browser APIs.
- [ ] Props crossing the boundary are serializable and minimal.
- [ ] Independent data fetched in parallel; slow parts wrapped in Suspense.
- [ ] Server Functions validate input and authorize every call.
- [ ] Server-only modules guarded with `server-only`.

Versions

RepositoryScoreLicence
This page · j4flmao/agent-skills100MIT
claude-dev-suite/claude-dev-suite100MIT
nextboxis/library-skill-agents100MIT
chrishuffman5/domain-expert100MIT
Thisisjuke/skills90MIT

Database snapshot: 13.11.2026 · package version bd43a66daae8 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100server-component-patterns
    React Server Components vs Client Components in Next.js: the boundary discipline, "use client" / "use server" directives, Server Actions, what serializes across the boundary, common pitfalls. Use this skill to: - Decide whether a component should be RSC or Client. - Push the…
  • 100nextjs-server-components
    Build async React Server Components and place 'use client' boundaries at leaf nodes for interactivity in Next.js App Router. Use when deciding RSC vs Client Component, composing server data into client wrappers, or fixing hydration errors.
  • 100nextjs-server-components
    Use this skill when the user says 'Next.js server components', 'fetch data in a server component', 'Next.js streaming', 'loading.tsx', 'Suspense in Next.js', 'reduce client JS in Next.js', 'hydration error', 'server actions in Next.js', 'parallel data fetching Next.js'. It…
  • 100react-rsc
    Use when working with React Server Components — choosing between Server and Client components, designing the server/client boundary, debugging hydration mismatches, fetching data on the server, using Server Actions, optimizing initial load, or migrating from a Pages Router or…
  • 95nextjs-internals
    Use this skill when the user says 'how does Next.js render', 'RSC payload', 'Next.js streaming internals', 'partial prerendering', 'cache components', 'use cache', 'static vs dynamic route', 'why is my route dynamic', 'router cache', 'Next.js request lifecycle'. It explains how…
  • 100nextjs-testing
    Testing strategies for Next.js: Server Components, Client Components, Server Actions, Route Handlers, end-to-end with Playwright. Vitest/Jest configuration, React Testing Library patterns, msw for network mocks. Use this skill to: - Pick the right test layer for what you're…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.