react-19
Guide for React 19 development with Actions, Server Components, and new hooks. Use for building React 19 apps, form handling, optimistic updates, and migrations.
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o react-19.zip https://jpskill.com/download/17722.zip && unzip -o react-19.zip && rm react-19.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/17722.zip -OutFile "$d\react-19.zip"; Expand-Archive "$d\react-19.zip" -DestinationPath $d -Force; ri "$d\react-19.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
react-19.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
react-19フォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 7
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
React 19
React 19 (2024年12月以降安定版) は、非同期処理を簡素化し、SSRを改善し、Actions、Server Components、および新しいhooksでDXを強化します。
いつ使うか
- React 19 アプリケーションの構築
- 自動的な保留/エラー状態による非同期フォーム処理
- SSRのためのServer Components
- 楽観的なUI更新
- React 18からの移行
- フルスタックフォームのためのServer Actions
インストール
npm install react@19.2.1 react-dom@19.2.1
npm install --save-dev @types/react@19.0.0 @types/react-dom@19.0.0
必須: tsconfig.json で modern JSX transform を有効にします:
{ "compilerOptions": { "jsx": "react-jsx" } }
コアコンセプト
Execution Boundaries
| タイプ | 実行場所 | 状態 | アクセス |
|---|---|---|---|
| Server Component | サーバー | いいえ | DB, FS, Secrets |
| Client Component | ブラウザ | はい | DOM, Browser APIs |
| Server Action | サーバー | いいえ | DB, APIs |
規約
"use server"= Server Action"use client"= Client Component- ディレクティブなし = Server Component (RSC環境)
asyncコンポーネント = 自動的に中断
必須パターン
1. useActionState を使用したフォーム
'use client';
import { useActionState } from 'react';
function SignupForm() {
const [state, formAction, isPending] = useActionState(
async (prev, formData) => {
const error = await createUser(formData.get('email'));
return error ? { error } : null;
},
{ error: null }
);
return (
<form action={formAction}>
<input type="email" name="email" required />
<button disabled={isPending}>
{isPending ? 'Signing up...' : 'Sign Up'}
</button>
{state.error && <p>{state.error}</p>}
</form>
);
}
2. 楽観的な更新
'use client';
import { useOptimistic } from 'react';
function Comments({ comments, addComment }) {
const [optimistic, addOptimistic] = useOptimistic(
comments,
(curr, newComment) => [...curr, { ...newComment, pending: true }]
);
return (
<div>
{optimistic.map(c => <div key={c.id}>{c.text}</div>)}
<form action={async (formData) => {
addOptimistic({ id: Date.now(), text: formData.get('text') });
await addComment(formData);
}}>
<input name="text" />
<button>Post</button>
</form>
</div>
);
}
3. Server Actions
'use server';
export async function createPost(formData) {
const title = formData.get('title');
if (!title || title.length < 3) {
return { error: 'Title too short' };
}
await db.posts.create({ title });
revalidatePath('/posts');
}
4. Suspense によるストリーミング
export default function Dashboard() {
return (
<div>
<Suspense fallback={<Skeleton />}>
<RevenueCard />
</Suspense>
<Suspense fallback={<Skeleton />}>
<UsersCard />
</Suspense>
</div>
);
}
async function RevenueCard() {
const data = await db.analytics.getRevenue();
return <div>{data}</div>;
}
セキュリティの要点
// 1. 常に認証する
'use server';
export async function deleteUser(id) {
const user = await getCurrentUser();
if (!user) throw new Error('Unauthorized');
await db.users.delete(id);
}
// 2. シークレットをサーバー側に保持する
'use server';
export async function fetchData() {
const secret = process.env.API_SECRET; // 関数内!
return fetch(url, { headers: { Authorization: `Bearer ${secret}` }});
}
// 3. 入力を検証する
import { z } from 'zod';
const schema = z.object({ email: z.string().email() });
const result = schema.safeParse(formData);
完全なセキュリティガイダンスについては、references/security-guide.md を参照してください。
React 18 からの移行
- まず React 18.3 にアップデートする (警告を修正)
- React 19 にアップデートする:
npm install react@19 react-dom@19 - codemods を実行する:
npx codemod@latest react/19/migration-recipe - TypeScript を修正する:
npx types-react-codemod@latest preset-19 ./src - 徹底的にテストする
主な破壊的変更:
ReactDOM.render→createRootPropTypes削除 → TypeScript を使用forwardRef非推奨 →refを prop として使用useRef()は引数が必要 →useRef(null)
references/upgrade-checklist.md および references/migration-patterns.md を参照してください。
クイックリファレンス
新しい Hooks
| Hook | 目的 |
|---|---|
useActionState |
非同期アクションによるフォームの状態 |
useOptimistic |
即時のUIフィードバック |
use() |
promises/context を読み取る (条件付きで使用可能) |
useTransition |
緊急性の低い更新 |
詳細な API ドキュメントについては、references/hooks-api.md を参照してください。
いつ何を使うか
| タスク | 解決策 |
|---|---|
| フォーム | useActionState + Server Actions |
| 即時のUI | useOptimistic |
| データフェッチ | async/await を使用した Server Components |
| Refs | 通常の prop としての ref |
| プログレッシブレンダリング | Suspense boundaries |
参照ファイル
- references/hooks-api.md - 完全な hook ドキュメント
- references/migration-patterns.md - 詳細な移行ガイド
- references/advanced-examples.md - 本番環境の例
- references/security-guide.md - セキュリティのベストプラクティス
- references/upgrade-checklist.md - ステップバイステップのアップグレード
- references/core-workflows.md - 完全な例を含む5つの必須パターン
リソース
- React 19 Docs: https://react.dev
- Next.js 15 Docs: https://nextjs.org/docs
バージョン: 2.1 | 更新日: 2025-12-27
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
React 19
React 19 (stable since Dec 2024) simplifies async operations, improves SSR, and enhances DX with Actions, Server Components, and new hooks.
When to Use
- Building React 19 applications
- Async form handling with automatic pending/error states
- Server Components for SSR
- Optimistic UI updates
- Migrating from React 18
- Server Actions for full-stack forms
Installation
npm install react@19.2.1 react-dom@19.2.1
npm install --save-dev @types/react@19.0.0 @types/react-dom@19.0.0
Required: Enable modern JSX transform in tsconfig.json:
{ "compilerOptions": { "jsx": "react-jsx" } }
Core Concepts
Execution Boundaries
| Type | Runs | State | Access |
|---|---|---|---|
| Server Component | Server | No | DB, FS, Secrets |
| Client Component | Browser | Yes | DOM, Browser APIs |
| Server Action | Server | No | DB, APIs |
Conventions
"use server"= Server Action"use client"= Client Component- No directive = Server Component (in RSC environment)
asynccomponent = Auto-suspends
Essential Patterns
1. Forms with useActionState
'use client';
import { useActionState } from 'react';
function SignupForm() {
const [state, formAction, isPending] = useActionState(
async (prev, formData) => {
const error = await createUser(formData.get('email'));
return error ? { error } : null;
},
{ error: null }
);
return (
<form action={formAction}>
<input type="email" name="email" required />
<button disabled={isPending}>
{isPending ? 'Signing up...' : 'Sign Up'}
</button>
{state.error && <p>{state.error}</p>}
</form>
);
}
2. Optimistic Updates
'use client';
import { useOptimistic } from 'react';
function Comments({ comments, addComment }) {
const [optimistic, addOptimistic] = useOptimistic(
comments,
(curr, newComment) => [...curr, { ...newComment, pending: true }]
);
return (
<div>
{optimistic.map(c => <div key={c.id}>{c.text}</div>)}
<form action={async (formData) => {
addOptimistic({ id: Date.now(), text: formData.get('text') });
await addComment(formData);
}}>
<input name="text" />
<button>Post</button>
</form>
</div>
);
}
3. Server Actions
'use server';
export async function createPost(formData) {
const title = formData.get('title');
if (!title || title.length < 3) {
return { error: 'Title too short' };
}
await db.posts.create({ title });
revalidatePath('/posts');
}
4. Streaming with Suspense
export default function Dashboard() {
return (
<div>
<Suspense fallback={<Skeleton />}>
<RevenueCard />
</Suspense>
<Suspense fallback={<Skeleton />}>
<UsersCard />
</Suspense>
</div>
);
}
async function RevenueCard() {
const data = await db.analytics.getRevenue();
return <div>{data}</div>;
}
Security Essentials
// 1. Always authenticate
'use server';
export async function deleteUser(id) {
const user = await getCurrentUser();
if (!user) throw new Error('Unauthorized');
await db.users.delete(id);
}
// 2. Keep secrets server-side
'use server';
export async function fetchData() {
const secret = process.env.API_SECRET; // Inside function!
return fetch(url, { headers: { Authorization: `Bearer ${secret}` }});
}
// 3. Validate inputs
import { z } from 'zod';
const schema = z.object({ email: z.string().email() });
const result = schema.safeParse(formData);
See references/security-guide.md for complete security guidance.
Migration from React 18
- Update to React 18.3 first (fix warnings)
- Update to React 19:
npm install react@19 react-dom@19 - Run codemods:
npx codemod@latest react/19/migration-recipe - Fix TypeScript:
npx types-react-codemod@latest preset-19 ./src - Test thoroughly
Key breaking changes:
ReactDOM.render→createRootPropTypesremoved → Use TypeScriptforwardRefdeprecated → Userefas propuseRef()requires argument →useRef(null)
See references/upgrade-checklist.md and references/migration-patterns.md.
Quick Reference
New Hooks
| Hook | Purpose |
|---|---|
useActionState |
Form state with async actions |
useOptimistic |
Instant UI feedback |
use() |
Read promises/context (can be conditional) |
useTransition |
Non-urgent updates |
See references/hooks-api.md for detailed API docs.
When to Use What
| Task | Solution |
|---|---|
| Forms | useActionState + Server Actions |
| Instant UI | useOptimistic |
| Data fetching | Server Components with async/await |
| Refs | ref as regular prop |
| Progressive rendering | Suspense boundaries |
Reference Files
- references/hooks-api.md - Complete hook documentation
- references/migration-patterns.md - Detailed migration guide
- references/advanced-examples.md - Production examples
- references/security-guide.md - Security best practices
- references/upgrade-checklist.md - Step-by-step upgrade
- references/core-workflows.md - 5 essential patterns with full examples
Resources
- React 19 Docs: https://react.dev
- Next.js 15 Docs: https://nextjs.org/docs
Version: 2.1 | Updated: 2025-12-27
同梱ファイル
※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。
- 📄 SKILL.md (5,602 bytes)
- 📎 references/advanced-examples.md (20,547 bytes)
- 📎 references/core-workflows.md (7,855 bytes)
- 📎 references/hooks-api.md (14,992 bytes)
- 📎 references/migration-patterns.md (14,740 bytes)
- 📎 references/security-guide.md (8,881 bytes)
- 📎 references/upgrade-checklist.md (9,885 bytes)