react-patterns

Document React 19 patterns for Server Components, Actions, and hooks.

Updated Apr 5, 2026
One-click install
npx skills add https://github.com/rizaldiem/digital-invitation-web_V2 --skill react-patterns-rizaldiem
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-patterns
Source: https://github.com/rizaldiem/digital-invitation-web_V2/tree/main/.windsurf/skills/react-patterns
Command: npx skills add https://github.com/rizaldiem/digital-invitation-web_V2 --skill react-patterns-rizaldiem

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Provides a single, practical reference to apply React 19's new architecture and APIs so engineers can design components, forms, and server/client boundaries correctly and avoid common migration and performance pitfalls.

Core Features & Use Cases

  • Server vs Client Architecture: Clear guidance for deciding when to use Server Components, Client Components, and how to pass data and interactions between them.
  • Modern Hooks & Forms: Patterns and examples for use(), useOptimistic, useFormState, useFormStatus, useTransition, and other concurrent hooks.
  • Server Actions & Validation: Best practices for writing 'use server' actions, validating input, handling optimistic updates, and revalidating caches.
  • Performance & Compiler: Recommendations for using the React Compiler, avoiding premature memoization, and optimizing expensive computations.
  • TypeScript & Testing: Type-safe component patterns, generic components, and test strategies for server actions, optimistic updates, and Suspense flows.
  • Use Case: Migrating an existing Next.js codebase to React 19 by converting data fetching to Server Components, introducing Server Actions for mutations, and applying optimistic UI for smoother UX.

Quick Start

Use react-patterns to refactor a component to Server Component for data fetching and expose a small Client Component that uses useFormState and a 'use server' action to handle form submission.

Frequently Asked Questions about react-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use Server Components and Client Components together in React 19?

Server Components and Client Components in React 19 are combined by fetching data on the server and passing it to small Client Components for interactivity. This architecture ensures robust apps by correctly managing server/client boundaries and data flow.

What is the best way to handle form submissions with Server Actions in React 19?

Form submissions with Server Actions in React 19 are handled using 'use server' directives alongside useFormState and useFormStatus hooks. This pattern validates input, handles mutations, and revalidates caches for secure and efficient data updates.

How does useOptimistic work for optimistic updates in React?

useOptimistic in React works by immediately showing the expected state before the server mutation completes. It provides smooth UX during asynchronous Server Actions by reverting to the actual state once the server response is received.

Do I need to manually memoize components when using the React Compiler?

Manual memoization is unnecessary when using the React Compiler, as it automatically optimizes expensive computations and prevents unnecessary re-renders. Developers can avoid premature memoization and rely on the compiler for performance optimizations.

Can I use TypeScript with React 19 Server Components and Actions?

TypeScript is fully supported with React 19 Server Components and Actions. Type-safe component patterns and generic components ensure end-to-end type safety across server/client boundaries, form handling, and Suspense flows.

How do I migrate an existing Next.js codebase to React 19?

Migrating a Next.js codebase to React 19 involves converting data fetching to Server Components, introducing Server Actions for mutations, and applying optimistic UI. A migration checklist ensures correct Suspense and concurrent feature implementation.