Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Nextjs App Router?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/adityaaatiwari-nextjs-app-router)
---
name: nextjs-app-router
description: "Build and debug Next.js App Router features: server/client components, data fetching, caching and route handlers"
---
<!-- Generated by `anvil plugin build` from catalog/. Edit the catalog, not this file. -->
# 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.