server-actions

Standardize Next.js server mutations with authentication, Zod validation, and cache revalidation.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/endriwmsi/hub-ln --skill server-actions-endriwmsi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: server-actions
Source: https://github.com/endriwmsi/hub-ln/tree/main/.agent/skills/server-actions
Command: npx skills add https://github.com/endriwmsi/hub-ln --skill server-actions-endriwmsi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill standardizes the creation of Server Actions with authentication, Zod validation, and cache revalidation to reduce boilerplate and improve security.

Core Features & Use Cases

  • Authentication via verifySession to securely gate mutations.
  • Input validation using Zod schemas, with ownership checks where applicable.
  • Page/data consistency via revalidatePath after mutations.
  • Clear file structure examples for create, update, and delete actions.

Quick Start

Create a new action file following the standard pattern and wire it to verifySession, then run your app to perform a protected mutation and trigger a cache revalidation.

Frequently Asked Questions about server-actions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I secure Next.js server actions with authentication and input validation?

To secure Next.js server actions, you enforce authentication via verifySession, validate inputs using Zod schemas, and trigger cache revalidation. This approach standardizes secure server-side mutations while reducing boilerplate across create, update, and delete operations.

What is the best way to handle cache revalidation after Next.js server mutations?

The best way to handle cache revalidation after server mutations is to call revalidatePath within your server action. This ensures page and data consistency immediately after create, update, or delete operations execute successfully.

How do I implement ownership checks in server actions using Zod validation?

Implementing ownership checks in server actions requires applying Zod schemas to validate input data and explicitly verifying user ownership through a dedicated data-access layer before authorizing the mutation to proceed.

Do I need a data-access layer to standardize server actions in TypeScript?

Yes, a data-access layer is required to standardize server actions in TypeScript. It satisfies validation, authorization, and cache revalidation requirements while ensuring deterministic error handling and secure mutations.

Why does my server action skip authorization checks despite having Zod validation?

Server actions skip authorization when verifySession is not explicitly called. Enforcing authentication and input validation through Zod schemas must be actively wired to the action to gate mutations and prevent unauthorized access.