react-patterns

Implement React 19 patterns with Server Actions and TanStack Query mutations.

Updated Mar 3, 2026
One-click install
npx skills add https://github.com/jacexh/skills --skill react-patterns-jacexh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-patterns
Source: https://github.com/jacexh/skills/tree/main/skills/react-patterns
Command: npx skills add https://github.com/jacexh/skills --skill react-patterns-jacexh

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides clear, practical guidance for adopting React 19 features and patterns so teams can write compiler-friendly components, choose appropriate mutation strategies, and implement reliable form and optimistic-update flows without introducing anti-patterns.

Core Features & Use Cases

  • Compiler-friendly code: Guidance on writing pure, serializable props, avoiding unnecessary effects, and opt-out patterns for problematic components.
  • Actions vs Query guidance: Decision matrix and examples showing when to use React 19 Server Actions and useActionState/useOptimistic for form-centric workflows versus TanStack Query mutations for SPA interactions and complex optimistic rollbacks.
  • New hooks and composition: Examples for the use hook with Suspense, compound component patterns, error boundary implementations, and integration strategies for SSR/RSC and client-side SPAs.
  • Use Case: Build a todo app that uses form-based Server Actions for simple CRUD, optimistic UI for immediate feedback, and TanStack Query for non-form button-driven mutations and cache integration.

Quick Start

Create a React 19 component that uses a form-based Server Action with useActionState and useOptimistic to add todos with optimistic UI updates.

Frequently Asked Questions about react-patterns

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

FAQPage Schema
How do I implement React 19 Server Actions with useActionState for form submissions?

React 19 Server Actions with useActionState handle form-centric workflows directly within server components. This pattern provides reliable state management for form-centric CRUD operations without manual effect synchronization.

When should I use TanStack Query mutations vs React 19 Server Actions?

Use React 19 Server Actions and useActionState for form-centric workflows and simple CRUD operations. Choose TanStack Query mutations for SPA interactions, non-form button-driven events, and complex optimistic rollbacks requiring cache integration.

How do I add optimistic UI updates in a React 19 todo application?

You add optimistic UI updates in React 19 by pairing the useOptimistic hook with your mutation strategy. This provides immediate user feedback for actions like adding todos before the server response completes.

How do I write React Compiler-friendly components and avoid anti-patterns?

Writing React Compiler-friendly components involves creating pure components with serializable props and avoiding unnecessary effects. You can also apply opt-out patterns for problematic components to prevent the compiler from introducing anti-patterns.

Can I use the React 19 use hook with Suspense for async data fetching?

You can use the React 19 use hook with Suspense to handle asynchronous operations and data fetching. This composition pattern integrates seamlessly with error boundary implementations across both SSR/RSC and client-side SPA environments.

What is the best way to handle optimistic rollbacks for non-form mutations in React?

The best way to handle optimistic rollbacks for non-form button-driven mutations is using TanStack Query. It provides robust cache integration and automatic rollback strategies for complex SPA interactions where Server Actions are insufficient.