nextjs-patterns

nextjs-patterns is a skill for Claude Code, Codex from cosmicstack-labs/mercury-agent-skills. It costs 24 tokens per session (1,979 once invoked), scanned A, original, MIT.

A guide to building full-stack web applications with Next.js, including its App Router and Server Components. Next.js is a framework for building React websites and web applications.

In plain words
What is it for?
Use it to organize Next.js projects, create nested layouts and routes, fetch data on the server, and build loading, error, and not-found pages.
Why use it?
It helps developers choose a project structure and handle routing, data fetching, loading states, errors, caching, and streaming consistently.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to organize Next.js projects, create nested layouts and routes, fetch data on the server, and build loading, error, and not-found pages.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/cosmicstack-labs/mercury-agent-skills/nextjs-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add cosmicstack-labs/mercury-agent-skills --skill nextjs-patterns
Clone the repo
git clone --depth 1 https://github.com/cosmicstack-labs/mercury-agent-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for nextjs-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/cosmicstack-labs/mercury-agent-skills/nextjs-patterns/github.svg)](https://agentmods.dev/skills/cosmicstack-labs/mercury-agent-skills/nextjs-patterns)
Your own site
<a href="https://agentmods.dev/skills/cosmicstack-labs/mercury-agent-skills/nextjs-patterns"><img src="https://agentmods.dev/badge/skills/cosmicstack-labs/mercury-agent-skills/nextjs-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for nextjs-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/cosmicstack-labs/mercury-agent-skills/nextjs-patterns"><img src="https://agentmods.dev/badge/skills/cosmicstack-labs/mercury-agent-skills/nextjs-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 24 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,979 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00024 $0.01979
Opus 5.5 $0.00010 $0.00792
Sonnet 5.5 $0.00005 $0.00396
Haiku 4.5 $0.00002 $0.00198

Measured 1mo ago against content hash b826187b115d, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

nextjs-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

categories/frontend/nextjs-patterns/SKILL.md · 295 lines

How it starts

The opening of the file, as written. The whole thing — 295 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Next.js Patterns

Comprehensive guide to building production-grade Next.js applications with the App Router, Server Components, and modern React patterns.

Core Architecture

App Router vs Pages Router

Aspect App Router Pages Router
Components Server Components by default Client Components only
Routing File-system based with layout nesting File-system based, flat
Data Fetching Server-side fetch, use, cache primitives getServerSideProps, getStaticProps
Loading States loading.js files Manual implementation
Error Handling error.js files Manual implementation
Streaming Built-in with Suspense boundaries Not supported

Project Structure

my-app/
├── app/
│   ├── layout.tsx          # Root layout
│   ├── page.tsx            # Home page
│   ├── loading.tsx         # Root loading state
│   ├── error.tsx           # Root error boundary
│   ├── not-found.tsx       # 404 page
│   ├── (auth)/             # Route group
│   │   ├── login/page.tsx
│   │   └── register/page.tsx
│   ├── dashboard/
│   │   ├── layout.tsx      # Dashboard layout
│   │   ├── page.tsx        # Dashboard home
│   │   ├── loading.tsx
│   │   └── settings/
│   │       └── page.tsx
│   └── api/
│       └── [...route]/route.ts  # API handlers
├── components/
│   ├── ui/                 # Shared UI components
│   └── features/           # Feature-specific components
├── lib/
│   ├── db.ts              # Database client
│   ├── auth.ts            # Auth utilities
│   └── utils.ts           # Shared utilities
└── public/
    └── images/

Server Components (RSC)

When to Use Server vs Client

// ✅ SERVER COMPONENT (default) — Use for:
// - Data fetching from databases/APIs
// - Accessing backend resources directly
// - Keeping sensitive logic on server
// - Reducing client bundle size
// - SEO-critical content
async function ProductPage({ params }: { params: { id: string } }) {
  const product = await db.product.findUnique({ where: { id: params.id } });
  return <ProductDetail product={product} />;
}

// ✅ CLIENT COMPONENT — Use for:
// - Interactivity (onClick, onChange, etc.)
// - useState, useReducer, useEffect
// - Browser-only APIs
// - Custom hooks
// - Event listeners
'use client';
function AddToCartButton({ productId }: { productId: string }) {
  const [added, setAdded] = useState(false);
  return (
    <button onClick={() => { addToCart(productId); setAdded(true); }}>
      {added ? 'Added!' : 'Add to Cart'}
    </button>
  );
}

Read the full file on GitHub · 295 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 295 lines · 24 tokens per session scan A b826187b115d

Subscribe to this mod's changes

nextjs-patterns is a skill published in the GitHub repository cosmicstack-labs/mercury-agent-skills (487 stars, last pushed 2mo ago), licensed MIT. It adds 24 tokens to every session and 1,979 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

airflow-plugins

Builds Airflow 3.1+ plugins that embed FastAPI apps, custom UI pages, React components, middleware, macros, and operator links directly into the Airflow UI. Use when building anything custom inside Airflow 3.1+ that involves Python and a browser-facing interface - creating an Airflow plugin, adding a custom UI page or…

astronomer/agents · 147 tokens

nextjs

Use when building Next.js applications with the App Router. Covers server and client component boundaries, data fetching and caching, server actions, streaming, and rendering strategy. Trigger on "server or client component", "page shows stale data after a mutation", "route is unexpectedly dynamic", "server action not…

nimadorostkar/Claude-Skills-collection · 84 tokens

remix

Expert Remix (React Router v7) assistance covering Loaders, Actions, nested routing, optimistic UI, and Web Fetch standards. Use when developing resilient, full-stack React web applications.

G1Joshi/Agent-Skills · 40 tokens

modern-saas-builder

Founder-minded senior product engineer and SaaS architect skill. Use when building, planning, architecting, validating, designing, testing, securing, deploying, or monetizing modern SaaS products, micro-SaaS, web apps, AI agents, Web3/Base applications, agent commerce, or Telegram bots/Mini Apps. Always active when…

lijnati/modern-saas-builder-skills · 98 tokens

nextjs-app-router-patterns

Architect and implement modern Next.js App Router applications with Server Components (RSC), Server Actions, Parallel/Intercepting Routes, and Streaming SSR.

pedroiff0/awesome-skills · 36 tokens

react-vite-supabase-starter

A setup guide for new web apps using React, Vite, TypeScript, Tailwind CSS, shadcn/ui, TanStack tools, and Supabase. It uses a pnpm workspace monorepo, meaning one repository containing multiple related packages or apps.

TBSten/skills · 176 tokens