Get the FREE Ultimate OpenClaw Setup Guide →

nextjs-architecture

npx machina-cli add skill aiskillstore/marketplace/nextjs-architecture --openclaw
Files (1)
SKILL.md
3.4 KB

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

  • When designing Next.js application architecture
  • When migrating from Pages Router to App Router
  • When implementing Server Components
  • When optimizing Next.js performance
  • When making Next.js architecture decisions
  • When building full-stack Next.js applications

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:

  • Server Components by default
  • Client Components with 'use client'
  • Direct database access in Server Components
  • Streaming with Suspense

Performance

Strategies:

  • Static generation for known content
  • ISR for frequently changing content
  • Streaming for slow queries
  • Image optimization
  • Code splitting

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**
```typescript
// 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

- Next.js architecture design
- App Router migration
- Server Components implementation
- Next.js performance optimization
- Full-stack Next.js development

Source

git clone https://github.com/aiskillstore/marketplace/blob/main/skills/89jobrien/nextjs-architecture/SKILL.mdView on GitHub

Overview

This skill provides Next.js architecture expertise, covering App Router, Server Components, migration strategies, and performance optimization to help design scalable Next.js apps.

How This Skill Works

The skill guides you through architecture design, pattern selection (App Router, Server Components, streaming, and image optimization), and migration. It emphasizes server-first components, selective client components, and performance-focused best practices.

When to Use It

  • When designing Next.js application architecture
  • When migrating from Pages Router to App Router
  • When implementing Server Components
  • When optimizing Next.js performance
  • When building full-stack Next.js applications

Quick Start

  1. Step 1: Design the architecture for this Next.js application
  2. Step 2: Migrate this Pages Router app to App Router
  3. Step 3: Implement Server Components and apply performance strategies

Best Practices

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

Example Use Cases

  • App Router Migration example: Pages Router → App Router
  • Design App Router structure for a dashboard module
  • Server Components should render by default with selective Client Components
  • Migrate a Pages Router app to App Router using layout and page.tsx conversions
  • Performance optimization: static generation, ISR, streaming, and image optimization

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers