React 19 Modern Hooks & Compiler AI Agent Rules
Modernize AI coding agents for React 19 Compiler and Server Component architectures.
Eliminate obsolete React patterns. Teach AI models to write modern React 19 code using useActionState, useOptimistic, and clean unidirectional data flow.
Configuration Workbench
Select your agent format below to preview, copy, or download the configuration file.
# React 19 Cursor Rules
You are a Principal React 19 and TypeScript engineer.
## React 19 Primitives
- Rely on the React Compiler: Do NOT wrap functions in 'useCallback' or values in 'useMemo' by default.
- Pass 'ref' directly as a prop to function components. Do NOT use deprecated 'forwardRef'.
- For forms and async transitions, use 'useActionState', 'useFormStatus', and 'useOptimistic'.
- Use the 'use' hook for reading promises and React context conditionally or inside loops.
## Code Quality
- Functional components only. Zero class components.
- Strict TypeScript typing with explicit props interfaces.
- Accessibility: ARIA attributes, semantic buttons (type='button'|'submit'), keyboard navigable.
- Clean component breakdown: No monolithic files over 200 lines.Pro-tip: Place this file directly in the root directory of your React 19 & Modern Hooks project. AI agents like Cursor Composer, Claude Code, and GitHub Copilot will read it automatically on initialization.
Architectural Principles Enforced
When this configuration file is loaded into Cursor or Claude Code, the agent strictly enforces the following design invariants:
Leverage the React 19 Compiler: Avoid premature `useMemo` and `useCallback` unless isolating expensive external libraries.
Use `useActionState` instead of complex `useState` + `useEffect` combinations for asynchronous form submissions.
Implement `useOptimistic` for instantaneous UI feedback during network mutations.
Use `ref` as a standard prop; do not use the deprecated `forwardRef` API in React 19.
Clean separation of pure presentation components from stateful data hooks.
Installation & Repository Setup
Place in project root as `.cursorrules` or `.cursor/rules/react.mdc`.
Verified Agent Behavior Examples
Observe how the AI agent responds when prompted under these active rules.
Frequently Asked Questions
Is forwardRef still needed in React 19?
No. In React 19, `ref` can be passed as a standard prop directly to functional components. `forwardRef` is deprecated and will be removed in future releases.