nextjs-best-practices

Architect Next.js App Router patterns for server rendering, routing, and data flow.

132|22|Updated Dec 18, 2025
One-click install
npx skills add https://github.com/xenitV1/Antigravity-Workflows --skill nextjs-best-practices
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nextjs-best-practices
Source: https://github.com/xenitV1/Antigravity-Workflows/tree/main/skills/nextjs-best-practices
Command: npx skills add https://github.com/xenitV1/Antigravity-Workflows --skill nextjs-best-practices

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Next.js App Router patterns and component strategy can be complex; this Skill codifies best practices to help teams structure routes, components, and data fetching.

Core Features & Use Cases

  • Server vs Client Components guidance for App Router.
  • Data fetching strategies: static, ISR, no-store with examples.
  • Routing conventions: page.tsx, layout.tsx, loading.tsx, error.tsx, not-found.tsx.
  • Use Case: Example of a multi-section app requiring consistent server rendering and client interactivity.

Quick Start

To apply these practices, start by organizing routes with a shared layout, move interactive elements into client components, and implement data fetching using server components where possible.

Frequently Asked Questions about nextjs-best-practices

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

FAQPage Schema
How do I structure routes and components in Next.js App Router?

Next.js App Router uses file-based routing with page.tsx for pages, layout.tsx for shared structure, loading.tsx for suspense boundaries, error.tsx for error handling, and not-found.tsx for 404s. Organize routes in nested folders to create your site structure, then place these special files to define behavior at each level.

When should I use server components vs client components in Next.js?

Server components handle data fetching, database access, and backend logic by default in Next.js App Router. Use client components only for interactivity, event listeners, and browser APIs. This separation optimizes rendering, reduces client-side JavaScript, and improves performance.

What data fetching strategies should I use with Next.js App Router?

Next.js App Router supports three strategies: Static (cached by default), ISR (revalidate at intervals), and no-store (fetch fresh on every request). Choose static for static content, ISR for frequently updated data, and no-store for real-time information like user-specific or time-sensitive data.

How do I implement consistent server rendering across a multi-section app?

Use shared layouts to wrap multiple routes with common structure, move interactive elements into client components, and fetch data in server components at the layout or page level. This pattern ensures each section inherits consistent rendering and reduces prop drilling.

Can I use both static and dynamic data fetching in the same Next.js route?

Yes. A route can contain server components with both static fetch calls and dynamic no-store calls. However, if any component uses no-store, the entire route becomes dynamic. Use ISR or selective revalidation to balance freshness and performance across mixed data patterns.

What's the best way to organize routing conventions for a scalable Next.js app?

Follow Next.js conventions: use page.tsx for content, layout.tsx for shared UI at each level, group related routes in folders, and place error and loading handlers at appropriate nesting levels. This structure scales cleanly and makes data-fetching decisions transparent across the app.