React19 Concurrent Patterns
GitHubOfficialFirst committed by SaravananRajaramanDistributed by GitHub
- Skill
- Guidelines
- Software development
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured approach to migrating React applications to version 19. It emphasizes a two-phase strategy: first, ensuring that existing React 18 concurrent patterns remain intact and functional during the initial migration, and second, introducing new React 19 features like Actions, the use() hook, and improved Suspense patterns only after the migration is stabilized. It includes specific verification steps to prevent accidental breakage of concurrent logic.
What it does
- Validates that existing React 18 concurrent patterns are preserved during migration.
- Provides guidance on when to introduce new React 19 APIs.
- Offers patterns for using React 19 Actions with useActionState and useFormStatus.
- Demonstrates how to implement Suspense for data fetching using the use() hook.
- Includes command-line verification to check for accidental modification of concurrent patterns.
- Distinguishes between code-splitting and data-fetching use cases for Suspense.
When to use it
- When planning or executing a migration from React 18 to React 19.
- When you need to ensure concurrent mode features remain stable during a framework upgrade.
- When you are ready to refactor legacy form handling into the new React 19 Actions pattern.
- When adopting new data-fetching patterns using Suspense and the use() hook.
Advantages
- Reduces the risk of breaking concurrent features during the migration process.
- Provides a clear separation between migration stability and feature adoption.
- Simplifies form handling by replacing complex useReducer logic with Actions.
- Offers standardized patterns for modern data fetching and state management.
Usage examples
- “How do I verify that my concurrent patterns were not broken during the React 19 migration?”
- The agent provides a grep command to scan the codebase for key concurrent patterns like useTransition and useDeferredValue to ensure they remain untouched.
- “Show me how to replace my React 18 form logic with React 19 Actions.”
- The agent provides a side-by-side comparison showing the transition from useReducer to the useActionState hook.
- “How can I use Suspense for data fetching in React 19?”
- The agent explains the use() hook and provides patterns for memoizing promises to prevent unnecessary re-renders.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/github/react19-concurrent-patterns/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip react19-concurrent-patterns.zip -d .agents/skills
Documentation by SaravananRajaraman
React 19 Concurrent Patterns
React 19 introduced new APIs that complement the migration work. This skill covers two concerns:
Preserve existing React 18 concurrent patterns that must not be broken during migration
Adopt new React 19 APIs worth introducing after migration stabilizes
Part 1 Preserve: React 18 Concurrent Patterns That Must Survive the Migration
These patterns exist in React 18 codebases and must not be accidentally removed or broken:
createRoot Already Migrated by the R18 Orchestra
If the R18 orchestra already ran, ReactDOM.render → createRoot is done. Verify it's correct:
// CORRECT React 19 root (same as React 18):
import { createRoot } from 'react-dom/client';
const root = createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);useTransition No Migration Needed
useTransition from React 18 works identically in React 19. Do not touch these patterns during migration:
// React 18 useTransition unchanged in React 19:
const [isPending, startTransition] = useTransition();
function handleClick() {
startTransition(() => {
setFilteredResults(computeExpensiveFilter(input));
});
}useDeferredValue No Migration Needed
// React 18 useDeferredValue unchanged in React 19:
const deferredQuery = useDeferredValue(query);Suspense for Code Splitting No Migration Needed
// React 18 Suspense with lazy unchanged in React 19:
const LazyComponent = React.lazy(() => import('./LazyComponent'));
function App() {
return (
<Suspense fallback={<Spinner />}>
<LazyComponent />
</Suspense>
);
}Part 2 React 19 New APIs
These are worth adopting in a post-migration cleanup sprint. Do not introduce these DURING the migration stabilize first.
For full patterns on each new API, read:
references/react19-use.mdtheuse()hook for promises and contextreferences/react19-actions.mdActions, useActionState, useFormStatus, useOptimisticreferences/react19-suspense.mdSuspense for data fetching (the new pattern)
Migration Safety Rules
During the React 19 migration itself, these concurrent-mode patterns must be left completely untouched:
# Verify nothing touched these during migration:
grep -rn "useTransition\|useDeferredValue\|Suspense\|startTransition" \
src/ --include="*.js" --include="*.jsx" | grep -v "\.test\."If the migrator touched any of these files, review the changes the migration should only have modified React API surface (forwardRef, defaultProps, etc.), never concurrent mode logic.
Files
- ATTRIBUTION.mdAdded by AutoGineer907 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md2.8 KiB
- references/react19-actions.md9.4 KiB
- references/react19-suspense.md7.6 KiB
- references/react19-use.md5.0 KiB
references/react19-use.md
title: React 19 use() Hook Pattern Reference
React 19 use() Hook Pattern Reference
The use() hook is React 19's answer for unwrapping promises and context within React components. It enables cleaner async patterns directly in your component body, avoiding the architectural complexity that previously required separate lazy components or complex state management.
What is use()?
use() is a hook that:
Accepts a promise or context object
Returns the resolved value or context value
Handles Suspense automatically for promises
Can be called conditionally inside components (not at top level for promises)
Throws errors, which Suspense + error boundary can catch
use() with Promises
React 18 Pattern
// React 18 approach 1 lazy load a component module:
const UserComponent = React.lazy(() => import('./User'));
function App() {
return (
<Suspense fallback={<Spinner />}>
<UserComponent />
</Suspense>
);
}
// React 18 approach 2 fetch data with state + useEffect:
function App({ userId }) {
const [user, setUser] = useState(null);
useEffect(() => {
fetchUser(userId).then(setUser);
}, [userId]);
if (!user) return <Spinner />;
return <User user={user} />;
}React 19 use() Pattern
// React 19 use() directly in component:
function App({ userId }) {
const user = use(fetchUser(userId)); // Suspends automatically
return <User user={user} />;
}
// Usage:
function Root() {
return (
<Suspense fallback={<Spinner />}>
<App userId={123} />
</Suspense>
);
}Key differences:
use()unwraps the promise directly in the component bodySuspense boundary is still needed, but can be placed at app root (not per-component)
No state or useEffect needed for simple async data
Conditional wrapping allowed inside components
use() with Promises -- Conditional Fetching
// React 18 conditional with state
function SearchResults() {
const [results, setResults] = useState(null);
const [query, setQuery] = useState('');
useEffect(() => {
if (query) {
search(query).then(setResults);
} else {
setResults(null);
}
}, [query]);
if (!results) return null;
return <Results items={results} />;
}
// React 19 use() with conditional
function SearchResults() {
const [query, setQuery] = useState('');
if (!query) return null;
const results = use(search(query)); // Only fetches if query is truthy
return <Results items={results} />;
}use() with Context
use() can unwrap context without being at component root. Less common than promise usage, but useful for conditional context reading:
// React 18 always in component body, only works at top level
const theme = useContext(ThemeContext);
// React 19 can be conditional
function Button({ useSystemTheme }) {
const theme = useSystemTheme ? use(ThemeContext) : defaultTheme;
return <button style={theme}>Click</button>;
}Migration Strategy
Phase 1 No changes required
React 19 use() is opt-in. All existing Suspense + component splitting patterns continue to work:
// Keep this as-is if it's working:
const Lazy = React.lazy(() => import('./Component'));
<Suspense fallback={<Spinner />}><Lazy /></Suspense>Phase 2 Post-migration cleanup (optional)
After React 19 migration stabilizes, profile codebases for useEffect + state async patterns. These are good candidates for use() refactoring:
Identify patterns:
grep -rn "useEffect.*\(.*fetch\|async\|promise" src/ --include="*.js" --include="*.jsx"Target:
Simple fetch-on-mount patterns
No complex dependency arrays
Single promise per component
Suspense already in use elsewhere in the app
Example refactor:
// Before:
function Post({ postId }) {
const [post, setPost] = useState(null);
useEffect(() => {
fetchPost(postId).then(setPost);
}, [postId]);
if (!post) return <Spinner />;
return <PostContent post={post} />;
}
// After:
function Post({ postId }) {
const post = use(fetchPost(postId));
return <PostContent post={post} />;
}
// And ensure Suspense at app level:
<Suspense fallback={<AppSpinner />}>
<Post postId={123} />
</Suspense>Error Handling
use() throws errors, which Suspense error boundaries catch:
function Root() {
return (
<ErrorBoundary fallback={<ErrorScreen />}>
<Suspense fallback={<Spinner />}>
<DataComponent />
</Suspense>
</ErrorBoundary>
);
}
function DataComponent() {
const data = use(fetchData()); // If fetch rejects, error boundary catches it
return <Data data={data} />;
}When NOT to use use()
Avoid during migration stabilize React 19 first
Complex dependencies if multiple promises or complex ordering logic, stick with
useEffectRetry logic
use()doesn't handle retry;useEffectwith state is clearerDebounced updates
use()refetches on every prop change;useEffectwith cleanup is better
Requirements and compatibility
Written for: GitHub Copilot
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- First committed by
SaravananRajaraman
- Publisher
- GitHub (Official)
- Distributed by
- GitHub
- Source
- github/awesome-copilot · skills/react19-concurrent-patterns · commit 797337f
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Contributors
- SaravananRajaraman, stbenjam
AutoGineer is not affiliated with or endorsed by SaravananRajaraman or GitHub.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download react19-concurrent-patterns.zip