nextjs

Enforce Next.js 14/15 App Router patterns and correct anti-patterns.

25|7|Updated Mar 16, 2026
One-click install
npx skills add https://github.com/xoai/sage --skill nextjs-xoai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nextjs
Source: https://github.com/xoai/sage/tree/main/skills/nextjs
Command: npx skills add https://github.com/xoai/sage --skill nextjs-xoai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and anti-patterns (resource) and gates (resource) and constitution (resource) and patterns (resource) components.

What problem does it solve?

This Skill addresses the common pitfalls and anti-patterns that AI agents encounter when generating code for Next.js applications, particularly with the App Router. It ensures adherence to modern Next.js best practices.

Core Features & Use Cases

  • App Router Guidance: Enforces Server Components, correct data fetching, and caching strategies.
  • Anti-Pattern Correction: Actively prevents common mistakes like Pages Router contamination and overuse of 'use client'.
  • Use Case: When instructing an AI to build a new feature in a Next.js 15 project, this Skill ensures the generated code uses Server Components for data fetching, Server Actions for mutations, and avoids legacy patterns, leading to more performant and maintainable applications.

Quick Start

Use the nextjs skill to ensure all generated code follows App Router best practices.

Frequently Asked Questions about nextjs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use Next.js App Router server components for data fetching?

Next.js App Router server components fetch data directly on the server by default. This approach leverages async components to eliminate client-side fetching, ensuring generated code adheres to modern patterns and avoids unnecessary 'use client' directives.

What is the best way to migrate Next.js Pages Router patterns to App Router?

The best way to migrate Pages Router patterns is actively correcting anti-patterns like getServerSideProps contamination. Enforcing Next.js 14/15 App Router patterns shifts data fetching to server components and mutations to server actions for performant applications.

How do server actions work in Next.js 15 for mutations?

Server actions in Next.js 15 handle data mutations directly on the server without creating separate API routes. They enforce pattern compliance by replacing client-side fetch logic for submissions, keeping your application maintainable and performant.

When should I use 'use client' in a Next.js React application?

You should use 'use client' in a Next.js application only when you need client-side interactivity or browser APIs. Overusing it creates anti-patterns; server components should handle data fetching and static rendering to maintain optimal performance.

Why does my Next.js AI generated code include legacy patterns?

AI generated code includes legacy patterns due to Pages Router contamination from outdated training data. Validating generated output against a Next.js-specific constitution and pattern compliance gates actively corrects these common anti-patterns.

Does this Next.js skill validate caching strategies for server components?

Yes, this Next.js skill validates caching strategies for server components. It enforces correct data fetching and caching mechanisms, ensuring your App Router implementation follows the latest framework best practices for optimal performance.