Skip to content

Next.js Server Actions guide for defining, validating, and revalidating data mutations in the App Router.

CCM score
57 of 100
skills.sh installs
204
GitHub stars
3.8K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers defining Server Actions inline in Server Components or in separate 'use server' files, plus form handling with validation
  • Explains state and feedback hooks useFormState and useFormStatus, along with optimistic updates via useOptimistic
  • Documents cache revalidation with revalidatePath and revalidateTag, plus redirects and error handling after actions
  • Includes a security section on input validation, authentication checks, and ownership checks before deleting records

Install

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

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

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'

Details

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

Questions

What does the server-actions skill help with in Next.js?

The server-actions skill guides data mutations and form submissions in the Next.js App Router. It covers defining Server Actions with the 'use server' directive, form handling with validation, useFormState and useFormStatus, revalidation with revalidatePath and revalidateTag, redirects, optimistic updates and error handling.

How do I install the server-actions skill?

Run npx -y skills add davepoon/buildwithclaude --skill server-actions -y in your project. Once installed, the agent can answer questions on Next.js Server Actions and form handling.

Who is the server-actions skill for?

It is for developers building with Next.js App Router who need to handle mutations and form submissions. It triggers on questions about useFormState, useFormStatus, revalidatePath and revalidateTag.

Where does server-actions stand in its category?

It sits in the Frontend & UI Code category, where web-design-guidelines and design-taste-frontend are among the other skills listed. It focuses on server-side mutation patterns rather than general frontend design guidance.

Does the server-actions skill cover security?

Yes, the skill includes security considerations such as validating input, checking authentication and authorization before a mutation, and sanitizing output. It shows an example that verifies the session and post ownership before deleting.

More from davepoon/buildwithclaude

All 2

Similar to Server Actions

More Frontend & UI Code