nextjs-tailwind — GitHub Copilot rule for Next.js
This rule guides GitHub Copilot on Next.js, TypeScript, and Tailwind CSS projects. Use it when asking for changes to routes, components, data handling, or styling.
.github/instructions/nextjs-tailwind.instructions.mdWhat nextjs-tailwind does
The instructions cover the App Router, server and client components, TypeScript types, and data fetching. They favor React Server Components by default, recommend grouping routes by feature, and call for loading and error states. Zod appears as the suggested library for runtime validation.
For the UI, the rule addresses responsive layouts, dark mode, semantic HTML, and container queries. It also calls out next/image, next/font, route prefetching, and code splitting. Security guidance includes input validation, authentication checks, and CSRF protection. These are instructions for Copilot to follow, not working implementations of those features; generated changes still need to fit the project’s existing structure and dependencies.
The rule applies to .tsx, .ts, .jsx, .js, and .css files. Its routing guidance assumes the App Router, so projects using a different routing setup need that advice adapted to their architecture.
What it helps with
- organize components and routes around App Router features
- add TypeScript definitions and Zod runtime validation
- handle loading and error states in data-driven pages
- style responsive interfaces with Tailwind CSS
- review API routes for input checks and CSRF protection
Example prompts for the agent
- Create an App Router page with a server component and TypeScript types.
- Review this API route and add input validation and error handling.
- Update the Tailwind styles for responsive layouts and dark mode.
How to install nextjs-tailwind
Manually: put the files in place
.github/instructions/nextjs-tailwind.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.claude/rules/nextjs-tailwind.mdThe paths frontmatter field limits the files: move applyTo from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/nextjs-tailwind.mdcFrontmatter: description, globs, alwaysApply. Move applyTo from the source into globs, or the rule will not attach on its own
Manually: put the files in place
.devin/rules/nextjs-tailwind.mdManually: put the files in place
.clinerules/nextjs-tailwind.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about nextjs-tailwind
How do I install nextjs-tailwind in GitHub Copilot?
Add the rule file at .github/instructions/nextjs-tailwind.instructions.md.
What does the nextjs-tailwind rule do?
It gives Copilot project guidance for Next.js App Router, TypeScript, and Tailwind CSS, including data fetching, styling, security, and tests.
Which files does nextjs-tailwind apply to?
It applies to .tsx, .ts, .jsx, .js, and .css files.
Source text
nextjs-tailwind.instructions.md · MIT
--- description: 'Next.js + Tailwind development standards and instructions' applyTo: '**/*.tsx, **/*.ts, **/*.jsx, **/*.js, **/*.css' --- # Next.js + Tailwind Development Instructions Instructions for high-quality Next.js applications with Tailwind CSS styling and TypeScript. ## Project Context - Latest Next.js (App Router) - TypeScript for type safety - Tailwind CSS for styling ## Development Standards ### Architecture - App Router with server and client components - Group routes by feature/domain - Implement proper error boundaries - Use React Server Components by default - Leverage static optimization where possible ### TypeScript - Strict mode enabled - Clear type definitions - Proper error handling with type guards - Zod for runtime type validation ### Styling - Tailwind CSS with consistent color palette - Responsive design patterns - Dark mode support - Follow container queries best practices - Maintain semantic HTML structure ### State Management - React Server Components for server state - React hooks for client state - Proper loading and error states - Optimistic updates where appropriate ### Data Fetching - Server Components for direct database queries - React Suspense for loading states - Proper error handling and retry logic - Cache invalidation strategies ### Security - Input validation and sanitization - Proper authentication checks - CSRF protection - Rate limiting implementation - Secure API route handling ### Performance - Image optimization with next/image - Font optimization with next/font - Route prefetching - Proper code splitting - Bundle size optimization ## Implementation Process 1. Plan component hierarchy 2. Define types and interfaces 3. Implement server-side logic 4. Build client components 5. Add proper error handling 6. Implement responsive styling 7. Add loading states 8. Write tests
© github · MIT · github/awesome-copilot