agentleFS
Rikinshah787Rikinshah787/agent-skills-production-skills/skills/nextjs/SKILL.md

nextjs

Skill2 starsChanged 4 months agoMITView on GitHub

Use to build production React applications with the App Router, Server Components, Route Handlers, caching, metadata, and deployment.

  • Reads credentials

19 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use tailwind, shadcn-ui and 1 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • nth5693Skill

    tailwind

    Also in 3 projects that use this

  • akornmeierSkill

    shadcn-ui

    Use when building React UIs with component libraries, implementing forms, dialogs, navigation, or data display. Use when user mentions shadcn, Radix UI, Base UI, or asks about accessible React components. Proactively suggest when building UI that would benefit from pre-built accessible components with Tailwind CSS styling.

    Also in 3 projects that use this

  • VercelSkill

    react

    React renderer for json-render that turns JSON specs into React components. Use when working with @json-render/react, building React UIs from JSON, creating component catalogs, or rendering AI-generated specs.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 17 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use when: building a React app that needs SSR, static generation, APIs, or strong SEO.

    line 21
  2. Distinctive:

    Use when: you want server-side data access with small client bundles.

    line 22
  3. Distinctive:

    Don't use for: a static page that plain HTML or a small Vite app can handle more simply.

    line 23
  4. Very specific:

    Only NEXT_PUBLIC_* environment variables are bundled for the browser.

    line 139
  5. Very specific:

    Import server-only in modules that access credentials or privileged databases so client imports fail at build time.

    line 140

“Common” is measured: kept by at least 6 in 10 of the 17 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Next.js - Skillship

Build full-stack React apps with file-based routing, Server Components by default, API endpoints, streaming, caching, and production deployment built in.

🧭 When to use this skill

  • Use when: building a React app that needs SSR, static generation, APIs, or strong SEO.
  • Use when: you want server-side data access with small client bundles.
  • Don't use for: a static page that plain HTML or a small Vite app can handle more simply.

⚡ Quickstart

1. Create an app

npx create-next-app@latest my-app
cd my-app
npm run dev

2. Know the App Router files

app/
  layout.tsx          # shared UI; root layout includes <html> and <body>
  page.tsx            # /
  loading.tsx         # Suspense fallback for this segment
  error.tsx           # client-side error boundary
  blog/[slug]/page.tsx
  api/posts/route.ts  # /api/posts endpoint
public/               # static assets
proxy.ts              # request proxy in Next.js 16+

3. Fetch on the server by default

// app/posts/page.tsx - Server Component (no directive needed)
import "server-only";

export default async function PostsPage() {
  const response = await fetch("https://api.example.com/posts");
  if (!response.ok) throw new Error("Failed to load posts");
  const posts = await response.json();

  return <ul>{posts.map((post: { id: string; title: string }) => <li key={post.id}>{post.title}</li>)}</ul>;
}

🧩 Common recipes

Recipe: Add client interactivity at the smallest boundary

// app/ui/counter.tsx
"use client";

import { useState } from "react";

export function Counter() {
  const [count, setCount] = useState(0);
  return <button onClick={() => setCount(count + 1)}>Count: {count}</button>;
}

Adding "use client" makes that file and its imported module graph part of the client bundle.

Recipe: Dynamic route (Next.js 16 async params)

// app/posts/[slug]/page.tsx
export default async function PostPage({
  params,
}: {
  params: Promise<{ slug: string }>;
}) {
  const { slug } = await params;
  return <h1>{slug}</h1>;
}

Recipe: Route Handler

// app/api/posts/route.ts
export async function GET() {
  const posts = await getPosts();
  return Response.json(posts);
}

export async function POST(request: Request) {
  const body = await request.json();
  const post = await createPost(body);
  return Response.json(post, { status: 201 });
}

Route Handlers support GET, POST, PUT, PATCH, DELETE, HEAD, and OPTIONS. They are not cached by default. A route.ts and page.tsx cannot occupy the same route segment.

Recipe: Static metadata

// app/layout.tsx
import type { Metadata } from "next";

export const metadata: Metadata = {
  title: { default: "Acme", template: "%s | Acme" },
  description: "Acme application",
};

Recipe: Keep secrets server-only

// lib/data.ts
import "server-only";

export async function getPrivateData() {
  return fetch("https://api.example.com/private", {
    headers: { authorization: `Bearer ${process.env.API_KEY}` },
  });
}

🚀 Ship to production

  • npm run build passes locally and production env vars are configured on the host.
  • Secrets stay server-side; only intentionally public values use NEXT_PUBLIC_.
  • "use client" appears only around interactive/browser-dependent UI, not whole layouts.
  • loading.tsx, error.tsx, and not-found.tsx cover expected states.
  • Metadata, sitemap.ts, robots.ts, icons, and Open Graph images are configured.
  • Dynamic routes, Route Handler caching, and revalidation behavior are intentional.

🔐 Security & secrets

  • Only NEXT_PUBLIC_* environment variables are bundled for the browser. Never use that prefix for secrets.
  • Import server-only in modules that access credentials or privileged databases so client imports fail at build time.
  • Authenticate and authorize inside Route Handlers and Server Actions close to the protected data.

🐛 Common errors & fixes

SymptomLikely causeFix
useState or event-handler errorComponent is still a Server ComponentAdd "use client" to the smallest interactive component
Secret is empty in client codeNon-public env vars are server-onlyMove the operation to a Server Component/Handler
Dynamic param is a PromiseNext.js 16 async request APIType params as a Promise and await params
page.tsx and route.ts conflictSame route segment owns bothMove the handler under app/api/...
Stale or unexpectedly dynamic dataCaching assumption is wrongSet explicit caching/revalidation behavior and verify it

📚 Sources

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.