api-routes

Create Next.js API endpoints with App Router and Pages Router.

Updated Apr 10, 2026
One-click install
npx skills add https://github.com/theslashdojo/dojo --skill api-routes-theslashdojo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-routes
Source: https://github.com/theslashdojo/dojo/tree/main/nodes/nextjs/api-routes
Command: npx skills add https://github.com/theslashdojo/dojo --skill api-routes-theslashdojo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

Expose backend functionality in Next.js apps by providing API endpoints through both App Router Route Handlers and Pages Router API Routes.

Core Features & Use Cases

  • Scaffold and manage API endpoints using Route Handlers (app/api/...) and Pages Router (pages/api/...) for RESTful APIs and webhooks.
  • Supports dynamic routes, streaming responses, and preflight CORS handling examples.
  • Use in projects needing backend logic, webhook endpoints, or serverless-like endpoints within Next.js.

Quick Start

Create a new App Router API route at app/api/items/route.ts implementing GET and POST handlers.

Frequently Asked Questions about api-routes

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

FAQPage Schema
How do I scaffold Next.js API endpoints using Route Handlers?

To scaffold Next.js API endpoints, you create Route Handlers in the App Router (app/api/...) or API Routes in the Pages Router (pages/api/...). This Skill generates robust handlers enforcing HTTP methods for RESTful APIs.

Do Next.js Route Handlers support streaming responses and CORS?

Yes, Next.js Route Handlers support streaming responses and CORS. This Skill provides ready-to-adapt examples for preflight CORS handling and streaming outputs within your serverless-like endpoints.

What is the difference between App Router Route Handlers and Pages Router API Routes?

App Router Route Handlers use app/api/... and Pages Router API Routes use pages/api/.... This Skill scaffolds both formats to expose backend functionality across modern Next.js projects.

Can I create webhook listeners in Next.js for external integrations?

Yes, you can create webhook listeners in Next.js. This Skill scaffolds webhook endpoints with ready-to-adapt examples, demonstrating proper handling for incoming external service requests.

How do I enforce HTTP methods in Next.js API routes?

You enforce HTTP methods in Next.js API routes by defining specific handlers like GET and POST. This Skill scaffolds these method-specific handlers to ensure your REST endpoints respond correctly.

Does this work for dynamic routes in modern Next.js projects?

Yes, this works for dynamic routes in modern Next.js projects. The Skill scaffolds dynamic API endpoints across both App Router and Pages Router, supporting serverless functions and backend logic.