api-routes

Create and manage Next.js API routes in src/pages/api/ with typed responses.

1|Updated Jan 12, 2026
One-click install
npx skills add https://github.com/jorggerojas/next-skeleton-page --skill api-routes-jorggerojas
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-routes
Source: https://github.com/jorggerojas/next-skeleton-page/tree/main/.cursor/skills/api-routes
Command: npx skills add https://github.com/jorggerojas/next-skeleton-page --skill api-routes-jorggerojas

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Create and manage Next.js API routes within src/pages/api/ to handle HTTP requests and server-side logic.

Core Features & Use Cases

  • Automatic routing of endpoints in src/pages/api/ and automatic exposure as API routes.
  • Examples cover GET, POST, PUT, and DELETE methods, including dynamic routes like /api/users/[id].
  • Enforces a consistent response shape using a standard HttpResponses type and clear error handling.

Quick Start

Create a simple API route at src/pages/api/hello.ts that handles GET requests and returns a structured JSON response.

Frequently Asked Questions about api-routes

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

FAQPage Schema
How do I create Next.js API routes using the Pages Router?

Next.js API routes using the Pages Router are created by adding TypeScript files to the src/pages/api/ directory, which automatically exposes them as HTTP endpoints to handle server-side requests and logic.

How does dynamic routing work for Next.js Pages Router endpoints?

Dynamic routing for Next.js Pages Router endpoints works by naming files with brackets, such as [id].ts, inside the src/pages/api/ folder to capture URL parameters and handle targeted HTTP requests.

What is the standard response structure for Next.js API routes?

A standard response structure for Next.js API routes uses a consistent HttpResponses type containing message, data, and status fields to ensure clear JSON responses and robust error handling across endpoints.

Do I need TypeScript to build Next.js API routes with the Pages Router?

TypeScript is used to build these Next.js API routes, utilizing NextApiRequest and NextApiResponse types to correctly type incoming HTTP requests and outgoing server responses in the Pages Router.

What HTTP methods are supported in Next.js Pages Router API routes?

Next.js Pages Router API routes support standard HTTP methods including GET, POST, PUT, and DELETE, allowing you to build REST-like endpoints and manage server-side logic for various request types.