AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MIT Self-run

Nextjs Server Actions And Route Handlers

skill-andrewsrigom-agent-skills-nextjs-server-actions-and-route-handlers · by andrewsrigom

Build safe mutation and API boundaries in Next.js App Router. Use when tasks mention `use server`, Server Functions, Server Actions, Route Handlers, `route.ts`, form `action`, `formAction`, cookies, redirects after mutations, request and response handling, or deciding between UI-driven mutation flow and explicit HTTP endpoints.

— No reviews yet
0 installs
32 views
0.0% view→install

Install

$ agentstack add skill-andrewsrigom-agent-skills-nextjs-server-actions-and-route-handlers

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • ✓ Prompt-injection patterns
  • ✓ Secret / credential exfiltration
  • ✓ Dangerous shell & filesystem operations
  • ✓ Untrusted network calls
  • ✓ Known-malicious package signatures

What it can access

  • ✓ Network access No
  • ✓ Filesystem access No
  • ✓ Shell / process execution No
  • ✓ Environment & secrets No
  • ✓ Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-andrewsrigom-agent-skills-nextjs-server-actions-and-route-handlers)

Reliability & compatibility

✓ Security review passed
0 installs to date
— no reviews yet
○ 5mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Nextjs Server Actions And Route Handlers? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Next.js Server Actions and Route Handlers

Use this skill when the task is primarily about mutation boundaries, server-only execution, or deciding whether code belongs in a Server Action or a Route Handler.

Scope

  • use server and Server Function placement
  • Server Actions for form and UI-driven mutations
  • Route Handlers for explicit HTTP endpoints
  • redirects, refreshes, cookies, and post-mutation cache invalidation
  • request and response handling with NextRequest and NextResponse
  • auth and validation guardrails for mutation surfaces

Routing cues

  • use server, form actions, mutation flow, cookies, redirects, or Route Handlers -> use this skill
  • cache strategy and invalidation ownership as the main question -> use nextjs-data-fetching-and-cache
  • metadata, sitemap, or robots concerns -> use nextjs-metadata-seo-and-file-conventions
  • runtime placement or proxy.ts as the main concern -> use nextjs-rendering-runtime-and-middleware

Default path

  1. Read [references/server-boundaries-and-handler-selection.md](./references/server-boundaries-and-handler-selection.md) first.
  2. Decide whether the caller is UI-bound or protocol-bound before writing code.
  3. Validate input and enforce auth inside every Server Action and Route Handler.
  4. Pair mutations with explicit cache refresh strategy instead of relying on incidental reloads.

When to deviate

  • Prefer a Route Handler when the caller is external, protocol-specific, or not driven by your own UI.
  • Prefer a Server Action when the mutation is initiated directly from your app UI or a form.
  • Move to the cache skill when the hard problem is invalidation strategy rather than mutation boundary choice.
  • Move to the runtime skill when the real question is execution placement or interception before the route runs.

Quick example

'use server'

import { revalidatePath } from 'next/cache'

export async function savePost(formData: FormData) {
  await db.post.create({
    data: { title: String(formData.get('title') ?? '') },
  })
  revalidatePath('/posts')
}

Guardrails

  • Server Functions are reachable by networked POST requests. Treat them as real server surfaces, not hidden callbacks.
  • Prefer Server Actions for mutations initiated by your own UI.
  • Prefer Route Handlers for webhooks, third-party callers, non-HTML clients, or protocol-specific behavior.
  • Keep secrets and privileged helpers on the server boundary only.
  • Use redirect, revalidatePath, revalidateTag, and cookies intentionally after successful mutations.

Avoid

  • treating Server Actions like private in-process callbacks with no auth or validation
  • using Route Handlers for every internal mutation just because they look familiar
  • relying on page reloads instead of explicit post-mutation cache strategy
  • mixing webhook or third-party API behavior into UI-centric Server Action guidance

Verification checklist

  • the caller is clearly classified as UI-bound or protocol-bound
  • auth and validation happen inside the server boundary
  • post-mutation redirect or invalidation behavior is explicit
  • secrets remain on the server side only
  • the chosen boundary is Server Action vs Route Handler for a reason, not by habit

Canonical APIs

  • use server
  • redirect
  • refresh
  • revalidatePath
  • revalidateTag
  • cookies
  • headers
  • NextRequest
  • NextResponse

Maintenance

  • Snapshot date: 2026-04-03
  • Package snapshot: next@16.2.2
  • Docs status snapshot: official docs distinguish the broad Server Function model from the narrower Server Action mutation pattern

References

  • [Server boundaries and handler selection](./references/server-boundaries-and-handler-selection.md)

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.