api-route

Generate Next.js 16 API Route Handlers with Zod validation and Prisma database operations.

4|1|Updated Sep 21, 2025
One-click install
npx skills add https://github.com/xmark168/VibeSDLC --skill api-route-xmark168
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-route
Source: https://github.com/xmark168/VibeSDLC/tree/main/backend/app/agents/developer/src/skills/nextjs/api-route
Command: npx skills add https://github.com/xmark168/VibeSDLC --skill api-route-xmark168

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill streamlines the creation of secure, validated, and efficient API routes within a Next.js 16 application, ensuring seamless data handling and robust error management.

Core Features & Use Cases

  • RESTful Endpoint Creation: Define GET, POST, PUT, DELETE handlers for CRUD operations.
  • Schema Validation: Implement data integrity using Zod for request bodies and parameters.
  • Prisma Integration: Safely interact with your database, adhering strictly to the prisma/schema.prisma definition.
  • Authentication & Authorization: Protect endpoints using NextAuth.js session management.
  • Error Handling: Utilize a standardized handleError function for consistent API responses.
  • Use Case: Develop a new API endpoint to create and retrieve user profiles, ensuring all incoming data is validated against a predefined schema and that only authenticated users can perform mutations.

Quick Start

Use the api-route skill to create a POST endpoint at /api/users that accepts a JSON body validated by a Zod schema and saves it to the database using Prisma.

Frequently Asked Questions about api-route

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

FAQPage Schema
How do I build Next.js API routes with Zod validation and Prisma?

Build Next.js API routes with Zod validation and Prisma by generating Route Handlers that validate request bodies with Zod schemas and execute database operations strictly adhering to your Prisma schema definitions for data integrity.

What is the best way to handle errors in Next.js RESTful endpoints?

Handle errors in Next.js RESTful endpoints by utilizing a standardized handleError function, which catches exceptions from your Route Handlers and returns consistent API responses for robust error management.

Can I use NextAuth.js session checks to protect Next.js API routes?

You can use NextAuth.js session checks to protect Next.js API routes by implementing authentication and authorization guards within your Route Handlers, ensuring only authenticated users can perform mutations.

How do I create CRUD operations for a RESTful endpoint in Next.js 16?

Create CRUD operations for a RESTful endpoint in Next.js 16 by defining collection and resource routes, mapping HTTP methods like GET, POST, PUT, and DELETE to specific Route Handlers for data retrieval and mutations.

Does Next.js 16 Route Handler validation enforce strict database schemas?

Next.js 16 Route Handler validation enforces strict database schemas by using Zod for incoming request bodies and strict adherence to the prisma/schema.prisma definition during database operations to guarantee data integrity.