Nextjs architecture

From aiskillstore/marketplace · View interactive version

Nextjs architecture is an AI agent skill from the GitHub repository aiskillstore/marketplace. Next.js architecture specialist. Use when designing Next.js applications, migrating to App Router, implementing Server Components, or optimizing Next.js performance. Covers App Router, Server Components, and best practices.

How to use this skill

Skill file

Next.js Architecture

This skill provides Next.js architecture expertise including App Router, Server Components, performance optimization, and migration strategies.

When to Use This Skill

What This Skill Does

  1. Architecture Design: Designs Next.js application structure
  2. App Router: Implements App Router patterns and routing
  3. Server Components: Uses Server Components effectively
  4. Performance: Optimizes Next.js for production
  5. Migration: Migrates from Pages Router to App Router
  6. Best Practices: Applies Next.js best practices

How to Use

Design Architecture

Design the architecture for this Next.js application
Migrate this Pages Router app to App Router

Specific Patterns

Implement Server Components for this feature

Architecture Patterns

App Router Structure

app/
├── (auth)/
│   ├── login/page.tsx
│   └── register/page.tsx
├── dashboard/
│   ├── layout.tsx
│   ├── page.tsx
│   └── analytics/page.tsx
├── api/
│   └── users/route.ts
└── layout.tsx

Server Components

Pattern:

Performance

Strategies:

Examples

Example 1: App Router Migration

Input: Migrate Pages Router to App Router

Output:

## Next.js Migration: Pages Router → App Router

### Migration Steps

**1. Convert Layout**

// Before: pages/_app.tsx

export default function App({ Component, pageProps }) {

return <Component {...pageProps} />;

}

// After: app/layout.tsx

export default function RootLayout({ children }) {

return (

<html>

<body>{children}</body>

</html>

);

}


**2. Convert Pages**

// Before: pages/users/[id].tsx

export default function UserPage({ user }) {

return <UserProfile user={user} />;

}

// After: app/users/[id]/page.tsx

export default async function UserPage({ params }) {

const user = await getUser(params.id);

return <UserProfile user={user} />;

}

Best Practices

Next.js Architecture

  1. Server First: Use Server Components by default
  2. Client When Needed: Add 'use client' only when necessary
  3. Static When Possible: Generate static pages when feasible
  4. Stream Slow Queries: Use Suspense for slow data
  5. Optimize Images: Use Next.js Image component

Related Use Cases

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.