Define the mutation in an `actions.ts` module with `'use server'`, validate its input, authenticate/authorize inside the action, delegate storage to a DAL, and revalidate the affected tag or path: ```ts 'use server' export async function createPost(formData: FormData) { const title = String(formData.get('title') ?? '') if (!title.trim()) return { error: 'Title is required' } await requireUser() await posts.create({ title }) revalidatePath('/posts') } ``` Wire it with `<form action={createPost...
Installs into .claude/skills of the current project.
Are you the author of Nextjs Server Actions?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-nextjs-server-actions-agent-skills-standard)
Define the mutation in an `actions.ts` module with `'use server'`, validate its input, authenticate/authorize inside the action, delegate storage to a DAL, and revalidate the affected tag or path:
```ts
'use server'
export async function createPost(formData: FormData) {
const title = String(formData.get('title') ?? '')
if (!title.trim()) return { error: 'Title is required' }
await requireUser()
await posts.create({ title })
revalidatePath('/posts')
}
```
Wire it with `<form action={createPost}>` and expose pending/error state as needed.