Home › React › React + TypeScript Copilot path instructions

React + TypeScript Copilot path instructions

Path-specific Copilot instructions for React 19 + TypeScript .tsx files: components, hooks, accessibility, and tests.

GitHub CopilotReact

How to use

Save this as .github/instructions/react.instructions.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

.github/instructions/react.instructions.mdDownload  
---
applyTo: "**/*.tsx"
description: React component conventions
---

# React + TypeScript components

- Function components with a local `type Props`; named exports; one component per file.
- Keep components presentational where possible; data fetching goes through the project's data layer (TanStack Query, loaders, or server components), not `useEffect` + `fetch`.
- Derive state during render. Effects only for syncing with external systems, always with a cleanup.
- Pass `ref` as a regular prop (React 19); don't write new `forwardRef` wrappers.
- Lists use stable `key`s from data ids.
- Event handler props are named `onX`, handlers inside are `handleX`.
- Accessibility: semantic elements, labelled inputs, `alt` on images, `aria-label` on icon-only buttons, no click handlers on `div`s.
- Styling follows the file's existing approach (Tailwind classes via `cn()`, CSS modules); don't mix systems in one component.
- Never use `any`; type events (`React.ChangeEvent<HTMLInputElement>`) and children (`React.ReactNode`).

## Tests
Testing Library with `userEvent`; query by role/label. One test file per component next to it (`Button.test.tsx`).

Related rules

Angular 20 Copilot instructions

Copilot instructions for Angular 20 apps using standalone components, signals, and the new control flow.

GitHub CopilotAngular

Code review Copilot instructions

Copilot instructions focused on pull request review: what to flag, severity labels, and how to word comments.

GitHub CopilotAgent workflows

C# / .NET Copilot path instructions

Path-specific Copilot instructions for C# files on .NET 10: nullable types, async, records, and logging.

GitHub Copilot.NET / ASP.NET Core

Dockerfile Copilot path instructions

Path-specific Copilot instructions for Dockerfiles and compose files: multi-stage builds, non-root, and pinned images.

GitHub CopilotDocker

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.