Skip to content
Back to skills

Nextjs Route

ASecurity

Add a Next.js App Router page or route handler with the right runtime

  • 3 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 3, 2026
ai-agentsgonextjsapi

Works with

  • cli
  • api

Security analysis

A100/100

Scanned September 3, 2026

npx -y skills add black141312/ada --skill nextjs-route --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Nextjs Route?

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

Security grade badge for Nextjs Route
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/black141312-nextjs-route/badge)](https://www.skillsdirectory.com/skills/black141312-nextjs-route)

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
---
name: nextjs-route
description: Add a Next.js App Router page or route handler with the right runtime
category: frameworks
---

# Next.js Route

Use to add a new page or API endpoint under the Next.js App Router (`app/`), choosing server vs client and the correct file convention.

1. Pick the segment path under `app/` (e.g. `app/dashboard/`); use `[param]` for dynamic and `(group)` for layout grouping without a URL segment.
2. For UI, add `page.tsx` (a Server Component by default); add `loading.tsx`, `error.tsx`, or `layout.tsx` siblings as needed.
3. For an API endpoint, add `route.ts` and export async functions named after HTTP verbs (`GET`, `POST`, …) taking `(req: Request, { params })`.
4. Fetch data directly in async Server Components or in the handler; return `Response`/`NextResponse.json()` from route handlers.
5. Add `'use client'` at the top only for components needing state, effects, or browser APIs; keep data-fetching on the server.
6. Run `next dev`, hit the route, and confirm the rendered/JSON output and status codes.

## Rules
- A folder can't have both `page.tsx` and `route.ts` at the same segment — pick one.
- Server Components can't use hooks, event handlers, or `window`; push those into a `'use client'` child.
- Set `export const dynamic`/`revalidate` deliberately when you need caching or always-fresh data.
- Read dynamic params from the function args, not from `useParams`, inside Server Components and handlers.
- Don't leak secrets to the client — env vars without `NEXT_PUBLIC_` stay server-only; keep them out of client components.

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.

Comments

Loading comments…

Newsletter

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