React 19.2
JavaScript library for building user interfaces with Server Components, Actions, and automatic optimization via the React Compiler.
Dependency | Version | Status |
---|---|---|
Next.js | 15.5.4 | Compatible |
TypeScript | 5.9.2 | Compatible |
Node.js | 24.8.0 | Compatible |
Vercel AI SDK | 5.0.48 | Compatible |
Getting Started
React 19.2 comes automatically with Next.js 15.5. No additional configuration needed.
# Create new Next.js app with React 19.2
npx create-next-app@latest my-app
# Verify React version
npm list react react-dom
React 19.2 Auto-Installed
Integration Patterns
Server Actions with useActionState
React 19's useActionState hook simplifies form handling with automatic pending states.
1'use server'23export async function createUser(prevState: any, formData: FormData) {4 const name = formData.get('name') as string;5 const email = formData.get('email') as string;67 // Validate8 if (!name || !email) {9 return { error: 'Name and email required' };10 }1112 // Save to database13 const user = await db.users.create({ name, email });1415 return { success: true, user };16}
1'use client'23import { useActionState } from 'react';4import { createUser } from './actions';56export function UserForm() {7 const [state, formAction, isPending] = useActionState(createUser, null);89 return (10 <form action={formAction}>11 <input name="name" required />12 <input name="email" type="email" required />13 <button disabled={isPending}>14 {isPending ? 'Creating...' : 'Create User'}15 </button>16 {state?.error && <p className="error">{state.error}</p>}17 {state?.success && <p className="success">User created!</p>}18 </form>19 );20}
Server Components + AI Streaming
Combine React Server Components with Vercel AI SDK for streaming AI responses.
1import { openai } from '@ai-sdk/openai';2import { streamText } from 'ai';34export default async function AIResponse({ prompt }: { prompt: string }) {5 // Server Component - runs on server only6 const result = await streamText({7 model: openai('gpt-4'),8 prompt,9 });1011 // Stream text directly to client12 return result.textStream;13}
What Breaks in Production
Real issues we've encountered with React 19 and how to fix them.
Symptom: useFormStatus always returns pending: false even during submission
Cause: useFormStatus must be used in a component that's a child of the <form>
Fix: Extract button into separate component
// ❌ Wrong - useFormStatus in same component as form
function MyForm() {
const { pending } = useFormStatus(); // Always false!
return <form><button disabled={pending}>Submit</button></form>;
}
// ✅ Right - useFormStatus in child component
function SubmitButton() {
const { pending } = useFormStatus();
return <button disabled={pending}>Submit</button>;
}
function MyForm() {
return (
<form action={myAction}>
<SubmitButton />
</form>
);
}
Symptom: Components not automatically optimized despite React 19
Cause: React Compiler is opt-in, not automatic in React 19
Fix: Add babel-plugin-react-compiler to your build
// next.config.js
module.exports = {
experimental: {
reactCompiler: true, // Enable React Compiler
},
};
Symptom: TypeScript errors when using Context directly as Provider
Cause: React 19 allows <Context> instead of <Context.Provider>, but TypeScript types lag behind
Fix: Continue using <Context.Provider> until TypeScript 5.10
// ✅ Works in React 19 but TypeScript may complain
<MyContext value={value}>
{children}
</MyContext>
// ✅ Always works - use this for now
<MyContext.Provider value={value}>
{children}
</MyContext.Provider>