nextjs-api-patterns
Installation
SKILL.md
Next.js API Patterns
Overview
Reference guide for building robust API layers in Next.js using Route Handlers and Server Actions. Apply these patterns for validation, error handling, auth, and correct use of each mechanism.
Route Handler Design
Basic CRUD Route Handler
// app/api/posts/route.ts
import { NextRequest, NextResponse } from "next/server";
import { z } from "zod";
import { db } from "@/lib/db";
import { auth } from "@/lib/auth";