1 nextjs rules available
The single Copilot Next.js rule covers App Router development. Copilot surfaces differ: VS Code applies path-specific instructions, JetBrains does not, and GitHub.com uses them only for cloud agent and code review. The file targets app/ files and suits Copilot code review on pull requests.
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/nextjs.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: "app/**/*.ts,app/**/*.tsx,src/app/**/*.ts,src/app/**/*.tsx" --- # Next.js instructions for GitHub Copilot ## Focus for this project - In review, flag new "use client" directives on files that do not use state, effects, event handlers or browser APIs. - Flag synchronous access to params, searchParams, cookies() or headers() in Next.js 15+ projects. - Flag secrets or server-only imports reachable from client components. ## Next.js conventions - Check package.json for the Next.js major version and whether the project uses app/ (App Router) or pages/ (Pages Router); follow the router that already exists instead of mixing them. - Files under app/ are Server Components by default. Add "use client" only at the smallest component that needs state, effects, event handlers or browser APIs. - From Next.js 15, params, cookies() and headers() are asynchronous, and so is searchParams in page files: await them in pages, layouts, route handlers and generateMetadata. - Put API endpoints in route.ts files that export named HTTP-method functions (GET, POST, ...), and validate request bodies before using them. ## Before you finish - Run the project's lint script and next build (type errors and invalid route exports fail the build) 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 Next.js 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 code review to catch client-component sprawl and unawaited request APIs in pull requests that touch app/.
Review a pull request that adds "use client" to app/dashboard/page.tsx to fix a hydration warning.
A comment asking to keep the page a Server Component and move the interactive part into a child client component, plus a note on what caused the hydration warning if visible in the diff.
Content reviewed 2026-11-05. Confirm instruction activation in your installed client before relying on it.