Handles Next.js Server Actions for form submissions, mutations, and server-side operations in the App Router. Covers the 'use server' directive, FormData handling, validation with Zod, useFormState for error handling, useFormStatus for loading states, and revalidatePath/revalidateTag for cache invalidation. The examples are practical and span the common cases: basic forms, optimistic updates, authentication checks, and redirects after mutations. It's comprehensive enough that you won't need to context-switch to the docs for most form and data mutation work. The security section is brief but hits the important points about validation and authorization.

skills.sh installs
203
GitHub stars
3.7K
last updated
Aug 21, 2026

Install

$ npx -y skills add davepoon/buildwithclaude --skill server-actions --agent claude-code

Installs into .claude/skills of the current project.

Files

Next.js Server Actions

Overview

Server Actions are asynchronous functions that execute on the server. They can be called from Client and Server Components for data mutations, form submissions, and other server-side operations.

Defining Server Actions

In Server Components

Use the 'use server' directive inside an async function:

// app/page.tsx (Server Component)
export default function Page() {
  async function createPost(formData: FormData) {
    'use server'
    const title = formData.get('title') as string
    await db.post.create({ data: { title } })
  }

  return (
    <form action={createPost}>
      <input name="title" />
      <button type="submit">Create</button>
    </form>
  )
}

In Separate Files

Mark the entire file with 'use server':

// app/actions.ts
'use server'

export async function createPost(formData: FormData) {
  const title = formData.get('title') as string
  await db.post.create({ data: { title } })
}

export async function deletePost(id: string) {
  await db.post.delete({ where: { id } })
}

Form Handling

Basic Form

// app/actions.ts
'use server'

Sponsors

Details

Repository
github.com/davepoon/buildwithclaude
Categories
Frontend Development, Backend & APIs
First seen
Jun 3, 2026

More from davepoon/buildwithclaude

All 6
1hairyf avatarvitehairyf/skillsVite build tool configuration, plugin API, SSR, and Vite 8 Rolldown migration. Use when working with Vite projects, vite.config.ts, Vite plugins, or building li200skills.sh installs
2iii-hq avatariii-observabilityiii-hq/iiiOpenTelemetry-backed tracing, structured logs, metrics with rollups, alerts, sampling, and baggage for the engine — emit and query telemetry through `engine::*`195skills.sh installs
3iii-hq avatariii-browser-sdkiii-hq/iiiBrowser SDK for connecting to the iii engine from web applications via WebSocket. Use when building browser-based clients that register functions, invoke trigge194skills.sh installs
4prompt-security avatarclawsec-scannerprompt-security/clawsecAutomated vulnerability scanner for agent platforms. Performs dependency scanning (npm audit, pip-audit), multi-database CVE lookup (OSV, NVD, GitHub Advisory),194skills.sh installs
5aiskillstore avatarhook-developmentaiskillstore/marketplaceThis skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", 188skills.sh installs
6ingpoc avatarscroll-storytelleringpoc/skillsUse when creating interactive scroll-based storytelling experiences with mouse-following spotlight effects, animated SVG art, and the Anthropic design language.186skills.sh installs