Skip to content
Agentmart
Submit a tool

nextjs-architecture

Trigger: Creation or refactoring of pages, React components, routes, server actions, Server and Client Components in Next.js, use of 'use client', passing…

Skill by 2004sfm

IndexedMIT
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/2004sfm-nextjs-architecture

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Trigger: Creation or refactoring of pages, React components, routes, server actions, Server and Client Components in Next.js, use of 'use client', passing functions via props, performance optimization, data fetching.

Use cases: frontend, backend, data

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/nextjs-architecture

What's inside

Skill name
nextjs-architecture
Description
Trigger: Creation or refactoring of pages, React components, routes, server actions, Server and Client Components in Next.js, use of 'use client', passing functions via props, performance optimization, data fetching.
License
MIT
Instructions
83 lines in SKILL.md · view on GitHub

Before installing

  • Instructions call the network

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Next.js 15 & React Architecture

## Core Architecture
- **Server-First (Composition Pattern)**: Use React Server Components (RSC) by default. Pass data down to Client Components as props to keep the client bundle size near zero.
- **Data Mutations**: Use **Server Actions** for all backend communications. NO API routes (`app/api/...`) unless strictly required for external webhooks.
- **Caching & Fetching**: Utilize Next.js native caching. Avoid `useEffect` for data fetching; use Server Components `await fetch()`.
- **Image/Font Optimization**: Always use `next/image` and `next/font` (Geist) to protect Core Web Vitals. No unoptimized static assets.
- **State Management**: Derive state from props and URL search params before reaching for `useState` or heavy Contexts.

## Golden Rule: Client Components at the "Leaves" of the Tree

In Next.js (with the App Router), the main performance rule is to keep **Client Components as low as possible in the component tree** and let the parents be **Server Components**.

### What are Client Components?
They are React components that render in the user's browser instead of on the server. They are declared by placing the `"use client"` directive on the first line of the file.

### When should you use them?
You should use a Client Component **only when you need interactivity or access to the browser**. If your component doesn't do any of the following, it should be a Server Component:
* **Interactivity and Events:** `onClick`, `onChange`, `onSubmit`, etc.
* **State and Lifecycle:** `useState`, `useEffect`, `useReducer`, `useRef`.
* **Browser APIs:** `window`, `document`, `localStorage`, `navigator`.

### The "Contaminating Children" Problem
If you declare a parent component as a Client Component, **all child components you import within it will automatically become Client Components**. This downloads unnecessary code to the user's browser. Avoid wrapping large layouts in client boundaries.

### The Correct Pattern: Isolate Interactivity

**❌ What you should NOT do (Put "use client" at the very top):**
```tsx
"use client" // ❌ This turns static children into Client Components
import { useState } from 'react'
import HeavyStaticComponent from './HeavyStaticComponent'

export default function ParentPage() {
  const [open, setOpen] = useState(false)
  return (
    <div>
      <button onClick={() => setOpen(!open)}>Open</button>
      <HeavyStaticComponent /> 
    </div>
  )
}
```

**✅ What you SHOULD do (Create a "leaf" component):**
Create a small component just for interactivity and keep the parent on the server.

```tsx
// 1. The Child (Client Component)
"use client"
import { useState } from 'react'

export default function InteractiveButton() {
  const [open, setOpen] = useState(false)
  return <button onClick={() => setOpen(!open)}>Open</button>
}
```

```tsx
// 2. The Parent (Server Component) - Fast, lightweight and WITHOUT "use client"
import InteractiveButton from './InteractiveButton'
import HeavyStaticComponent from './HeavyStaticComponent'

export default function ParentPage() {
  return (
    <div>
      <InteractiveButton /> {/* Only this goes to the browser */}
      <HeavyStaticComponent /> {/* Server rendered */}
    </div>
  )
}
```

### Prop Serialization (Limitation)
**You cannot pass callback functions (e.g. `onClick={() => console.log("hello")}`) from a Server Component to a Client Component** unless it is a Server Action (`"use server"`).
- If you need a callback, declare it directly inside the Client Component.
- If you need parent/child communication, encapsulate both behaviors in the same Client Component or use the URL state.

## Clean Code & VaultLock Rules
- UI must follow the `ui-architecture` skill (Geist fonts, Jade color, Tailwind CSS).
- Types must follow the `typescript-zod` skill (NO `any`, strict interfaces).

From 2004sfm/vaultlock, MIT.

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Aug 24, 2026 (2 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from 2004sfm

Cite this page

nextjs-architecture skill. Agent Mart. https://agentmart.dev/skills/2004sfm-nextjs-architecture (last updated 2026-10-24)