kb-api
OfficialDesign safe Next.js server actions and APIs.
Software Engineering#zod#server actions#nextjs#route handlers#api error handling#revalidatePath#actionresult
AuthorTimeKast
Version1.0.0
Installs0
System Documentation
What problem does it solve?
It prevents inconsistent API behavior in Next.js 16+ by standardizing how server actions and route handlers handle validation, authorization, revalidation, and error responses.
Core Features & Use Cases
- ActionResult<T> Contract: Uses a discriminated union to reliably separate success data from user-facing error strings for cleaner consumer branching.
- Portable CRUD Action Signatures: Defines consistent
getEntities,getEntityById,createEntity,updateEntity, anddeleteEntitysemantics that work across projects. - Boundary-First Validation: Enforces Zod
safeParseexactly once at the action or route boundary to establish a clear trust boundary. - Success-Only Cache Invalidation: Applies
revalidatePathonly after a real mutation succeeds, and never on read-only actions. - Next.js 16+ Correctness for params/searchParams: Treats
paramsandsearchParamsas Promises and parses them safely withawait.
Quick Start
Implement your server action or route handler using the ActionResult<T> pattern, validate inputs with Zod safeParse at the boundary, and call revalidatePath only on the success path after the mutation completes.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: kb-api Download link: https://github.com/TimeKast/AgendaInteligente/archive/main.zip#kb-api Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.