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`).

More: all React rules · all GitHub Copilot rules

Related rules

React 19 + Vite SPA rules

Cursor rules for React 19 single-page apps on Vite 6+ with TypeScript, hooks, and Vitest.

CursorReact

TanStack Query v5 rules

Cursor rules for TanStack Query v5 in React: query keys, queryOptions, mutations, and cache invalidation.

CursorReact

Angular 20 Copilot instructions

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

GitHub CopilotAngular

Astro content site rules

Cursor rules for Astro 5 sites with content collections, islands, and zero-JS-by-default pages.

CursorAstro

Chrome extension (Manifest V3) rules

Cursor rules for building Manifest V3 browser extensions with TypeScript and minimal permissions.

CursorChrome extensions

htmx + server-rendered HTML AGENTS.md

AGENTS.md for htmx 2 apps with server-rendered templates (any backend), partials, and progressive enhancement.

AGENTS.mdhtmx

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.