Skip to content
Back to skills

Nextjs App Router

ASecurity

Build and debug Next.js App Router features: server/client components, data fetching, caching and route handlers

  • 7 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 30, 2026
ai-agentstypescriptreactnextjsapidatabasefrontend

Works with

  • cli
  • api

Security analysis

A100/100

Scanned November 30, 2026

npx -y skills add ansh44233/forge --skill nextjs-app-router --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Nextjs App Router?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Nextjs App Router
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ansh44233-nextjs-app-router/badge)](https://www.skillsdirectory.com/skills/ansh44233-nextjs-app-router)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
description: Build and debug Next.js App Router features: server/client components, data fetching, caching and route handlers
profile: standard
languages: typescript, react
tags: nextjs, react, frontend
---

# Next.js App Router

Use in projects with an `app/` directory and `next` in package.json. Check the installed Next.js major version first (`npm ls next`); caching defaults changed between 14 and 15, so read that version's docs before relying on them.

## Server vs client components
- Components are **server components by default**. Add `"use client"` only to the smallest leaf that needs state, effects, event handlers or browser APIs.
- Never import server-only modules (database clients, secrets) into a client component. Mark them with `import "server-only"` so a mistake fails the build.
- Pass serializable props from server to client components (no functions, class instances or Dates you expect to stay Dates).

## Data
- Fetch in server components or route handlers, close to where the data is used. Run independent requests in parallel with `Promise.all`.
- Be explicit about caching: `fetch(url, { cache: "no-store" })` for per-request data, `{ next: { revalidate: 60 } }` or tags for cached data, and `revalidatePath` / `revalidateTag` after mutations.
- Mutations: Server Actions (`"use server"`) or route handlers in `app/api/**/route.ts`. Validate input on the server even if the form validated it.
- Treat every Server Action as a public endpoint: check authentication and authorization inside it.

## Routing and UX
- `loading.tsx` for streaming fallbacks, `error.tsx` (a client component) for error boundaries, `not-found.tsx` with `notFound()`.
- `generateMetadata` for titles and Open Graph, not hand-written `<head>` tags.
- Use `next/image` with explicit sizes and `next/link` for internal navigation.

## Common bugs
- Hydration mismatch: rendering `Date.now()`, `Math.random()` or `window` checks during render. Move them into `useEffect` or render them on the server only.
- A page that should be dynamic is served stale: check for implicit caching and set `export const dynamic = "force-dynamic"` or `cache: "no-store"` deliberately.
- Environment variables: only `NEXT_PUBLIC_*` reach the browser. Never prefix a secret with it.

## Verify
`next build` (catches server/client boundary and type errors), then the project's tests, then load the changed route in `next dev` and check the browser console for hydration warnings.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.