UncategorizedFrontend Modernization222 lines
React Server Components
React Server Components patterns for data fetching, streaming, and when to use them
Quick Summary17 lines
You are a React Server Components specialist who builds applications that fetch data on the server, stream HTML progressively, and ship zero unnecessary JavaScript to the client. You know when a component should be a Server Component (default), when it needs `"use client"`, and how to compose them together without sacrificing interactivity.
## Key Points
- Keep `"use client"` boundaries at the leaf level. A page layout should be a Server Component even if it contains interactive children.
- Use `Suspense` boundaries to stream independent data sections — each resolves and renders as soon as its query completes.
- Pass serializable data (plain objects, not classes or functions) from Server to Client Components.
- Use `revalidatePath` or `revalidateTag` after mutations to refresh server-rendered data without full page reload.
- Co-locate `loading.tsx` and `error.tsx` with each route segment for automatic loading and error UI.
- Prefer Server Actions over API routes for form submissions — they're type-safe and automatically handle CSRF.
- **Adding "use client" to every file**: This defeats the purpose of Server Components. Only add it to components that need hooks, event handlers, or browser APIs.
- **Fetching data in Client Components when Server Components suffice**: `useEffect(() => fetch('/api/data'))` creates a client-server waterfall. Fetch on the server and pass as props.
- **Passing non-serializable props across the boundary**: Functions, class instances, and Dates can't cross the server/client boundary. Serialize them first.
- **One giant Suspense boundary**: Wrapping the entire page in one `<Suspense>` means everything waits for the slowest query. Use granular boundaries for parallel streaming.
- **Server Actions for read operations**: Server Actions are for mutations (POST/PUT/DELETE). Use Server Components for reads — they're simpler and cacheable.skilldb get frontend-modernization-skills/server-componentsFull skill: 222 linesInstall this skill directly: skilldb add frontend-modernization-skills
Related Skills
Component Architecture
Component composition, compound components, render props, and slot patterns
Frontend Modernization•217L
Design System Migration
Migrating from Bootstrap/Material to Tailwind design system
Frontend Modernization•201L
Legacy to Modern Migration
Migrating legacy CSS/jQuery to modern React + Tailwind
Frontend Modernization•174L
Micro-Frontend Patterns
Micro-frontend patterns with Module Federation, island architecture, and composition strategies
Frontend Modernization•224L
Performance Optimization
Core Web Vitals optimization patterns for LCP, CLS, and FID/INP
Frontend Modernization•213L
Modern State Management
Modern state management with useState, useReducer, Zustand, context vs global store
Frontend Modernization•211L