4 react rules available
Four Copilot rules match react: React guidelines and Next.js development (substantive), plus short component and CSS-styling rules. The file below is for Copilot on .tsx/.jsx files, with review-oriented checks because path-specific instructions also feed Copilot code review.
GitHub Copilot reads repository-wide custom instructions from .github/copilot-instructions.md and path-specific instructions from .github/instructions/*.instructions.md files with an applyTo glob. Copilot can also use AGENTS.md files, where the nearest file in the directory tree takes precedence. Which file types are honored depends on the surface: VS Code, Visual Studio, JetBrains, Xcode, Eclipse and GitHub.com differ.
.github/instructions/react.instructions.mdStarting point, not a tested configuration for your repository. Used for files matching applyTo on surfaces that support path-specific instructions. Review the instructions, adapt the file paths and run your project's existing checks.
--- applyTo: "**/*.tsx,**/*.jsx" --- # React instructions for GitHub Copilot ## Focus for this project - Generate buttons as <button>, not clickable <div>s, and give every form control a label. - Type props with an interface or type alias; do not use React.FC for new components. - In review, flag useEffect blocks that only copy props into state. ## React conventions - Write function components and custom hooks; call hooks only at the top level of components or other hooks. - Derive values during render instead of copying props into state, and do not use an effect only to transform data for rendering. - Check the react version in package.json: on React 19, function components receive ref as a regular prop and forwardRef is not needed for new components; on React 18 keep forwardRef. - In tests, query by role and accessible name with Testing Library rather than by class names or test IDs. ## Before you finish - Run the type checker (npx tsc --noEmit for TypeScript projects), the lint script and the component tests and report the actual output. If you cannot run them, say so and list the exact commands instead of saying they pass. - Summarize which of the rules above affected the change. - When reviewing a pull request, comment only where a change breaks one of these instructions and quote the instruction.
Create your own GitHub Copilot rules for React and share with the community.
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
Instruction support differs by surface: VS Code supports repository-wide, path-specific and AGENTS.md instructions; Visual Studio supports repository-wide and path-specific; JetBrains and Xcode use .github/copilot-instructions.md. GitHub's documentation describes AGENTS.md files stored anywhere in the repository, with the nearest file in the directory tree taking precedence, or alternatively a single CLAUDE.md or GEMINI.md in the root. Support differs by surface; GitHub's IDE page lists AGENTS.md among the instruction types for VS Code.
Documentation checked 2026-11-05: GitHub Docs: Adding repository custom instructionsGitHub Docs: Repository instructions in your IDE
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
You want Copilot to generate components that use semantic elements and labels and to flag inaccessible patterns in review.
Ask Copilot Chat: create a Modal component with a close button and focus handling.
A typed Modal rendering a dialog with an accessible name, a real <button> to close, Escape-key handling and focus returned to the trigger; tests querying by role.
Content reviewed 2026-11-05. Confirm instruction activation in your installed client before relying on it.
Copilot instructions for Next.js App Router code with awaited params, authenticated Server Actions, typed Route Handlers and explicit caching.