nextjs-patterns

nextjs-patterns is a skill for Claude Code, Codex from chandrudp29/skillhub. It costs 30 tokens per session (1,019 once invoked), scanned A, original, MIT.

A set of recommended patterns for building and reviewing Next.js 14 or newer web applications with the App Router, which organizes pages and layouts as files.

In plain words
What is it for?
Use it when structuring routes and components, fetching and caching data, handling errors and loading states, validating inputs, or preparing a Next.js app for deployment.
Why use it?
It reduces common mistakes around server-side code, browser-side code, data loading, navigation, images, validation, and deployment.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/chandrudp29/skillhub/nextjs-patterns
Any agent
npx skills add chandrudp29/skillhub --skill nextjs-patterns
Clone the repo
git clone --depth 1 https://github.com/chandrudp29/skillhub

Made for: Claude Code, Codex.

Per session 30 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,019 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00030 $0.01019
Opus 5 $0.00015 $0.00509
Sonnet 5 $0.00006 $0.00204
Haiku 4.5 $0.00003 $0.00102

Measured 3d ago against content hash 4024a13e2104, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 3d 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.

skills/nextjs-patterns/SKILL.md · 126 lines

How it starts

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

When to Use

Apply when building or reviewing Next.js 14+ applications using the App Router. Covers everything from component architecture to deployment.

Core Rules

  • Default to Server Components — add 'use client' only when you need interactivity, browser APIs, or React hooks
  • Never fetch in Client Components unless it's a user-triggered action — data belongs on the server
  • Co-locate page files: page.tsx, layout.tsx, loading.tsx, error.tsx in the same folder
  • Use next/image for every image — never a bare <img> tag
  • Use next/link for navigation — never <a href>
  • Validate all route params and search params with Zod before use

App Router Architecture

app/
  layout.tsx           # root layout (html, body)
  page.tsx             # homepage
  (auth)/              # route group — no URL segment
    login/page.tsx
    register/page.tsx
  dashboard/
    layout.tsx         # nested layout — sidebar, nav
    page.tsx           # /dashboard
    [id]/
      page.tsx         # /dashboard/123
      loading.tsx      # streaming skeleton
      error.tsx        # error boundary
  api/
    users/route.ts     # API route handler

Server vs Client Components

// Server Component (default) — runs on server, has async, no hooks
async function UserProfile({ userId }: { userId: string }) {
  const user = await db.user.findUnique({ where: { id: userId } });
  return <div>{user?.name}</div>;
}

// Client Component — interactive, uses hooks, browser APIs
'use client';
function LikeButton({ postId }: { postId: string }) {
  const [liked, setLiked] = useState(false);
  return <button onClick={() => setLiked(l => !l)}>{liked ? '❤️' : '🤍'}</button>;
}

Data Fetching & Caching

// Server Component data fetching
async function Posts() {
  // Cached by default, revalidates every 60s
  const posts = await fetch('https://api.example.com/posts', {
    next: { revalidate: 60 }
  }).then(r => r.json());

  // Or: no cache for real-time data
  const live = await fetch('...', { cache: 'no-store' });
}

// Server Actions for mutations
'use server';
async function createPost(formData: FormData) {
  const title = formData.get('title') as string;
  await db.post.create({ data: { title } });
  revalidatePath('/posts');
}

Read the full file on GitHub · 126 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. 3d ago First seen · 126 lines · 30 tokens per session scan A 4024a13e2104

Subscribe to this mod's changes

nextjs-patterns is a skill published in the GitHub repository chandrudp29/skillhub (13 stars, last pushed 2mo ago), licensed MIT. It adds 30 tokens to every session and 1,019 once invoked, about $0.0002 per session on Opus 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-08-30.

Related

Other skills, from other repositories

shadcn

Manages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI, including chat interfaces. Provides project context, component docs, and usage examples. Applies when working with shadcn/ui, component registries, presets, --preset codes, or any project with a components.json…

shadcn-ui/ui · 94 tokens

migrate-radix-to-base

Migrates React projects and components from Radix UI to Base UI. Use when asked to migrate from radix, move to base-ui, convert radix primitives, or switch a shadcn project's base library. Handles single components ("migrate accordion") and whole projects.

shadcn-ui/ui · 61 tokens

react-query-setup

Set up @trpc/tanstack-react-query with createTRPCContext(), TRPCProvider, useTRPC() hook, queryOptions/mutationOptions factories, query invalidation via queryClient.invalidateQueries with queryFilter, and type inference with inferInput/inferOutput.

trpc/trpc · 60 tokens

react-query-classic-migration

Migrate from @trpc/react-query (classic) to @trpc/tanstack-react-query. Run npx @trpc/upgrade CLI for automated codemod. Manually migrate remaining patterns: hook-based to options-factory, utils.invalidate to queryClient.invalidateQueries with queryFilter, provider changes.

trpc/trpc · 70 tokens

magic-ui

Use this skill when users want to add, customize, or troubleshoot Magic UI components in React/Next.js projects. It covers component selection, shadcn registry installation (@magicui/), integration patterns, and practical quality checks for accessibility and maintainability.

magicuidesign/magicui · 56 tokens

trigger-realtime-and-frontend

Trigger.dev client/frontend surface: subscribe to runs in realtime (runs.subscribeToRun and the @trigger.dev/react-hooks hook useRealtimeRun), consume metadata and AI/text streams in React (useRealtimeStream), trigger tasks from the browser (useTaskTrigger, useRealtimeTaskTrigger), and mint scoped frontend credentials…

triggerdotdev/trigger.dev · 148 tokens