api-routes

Next.js API Routes - Route handlers, middleware, edge runtime

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "api-routes" with this command: npx skills add pluginagentmarketplace/custom-plugin-nextjs/pluginagentmarketplace-custom-plugin-nextjs-api-routes

Api Routes Skill

Overview

Build API endpoints with Next.js Route Handlers and middleware.

Capabilities

  • Route Handlers: app/api/route.ts files
  • HTTP Methods: GET, POST, PUT, DELETE, PATCH
  • Request/Response: Web API standard
  • Middleware: Edge runtime processing
  • Dynamic Routes: [param] patterns

Examples

// app/api/users/route.ts
import { NextResponse } from 'next/server'

export async function GET() {
  const users = await db.users.findMany()
  return NextResponse.json(users)
}

export async function POST(request: Request) {
  const body = await request.json()
  const user = await db.users.create(body)
  return NextResponse.json(user, { status: 201 })
}

// app/api/users/[id]/route.ts
export async function GET(
  request: Request,
  { params }: { params: { id: string } }
) {
  const user = await db.users.findById(params.id)
  return NextResponse.json(user)
}

Middleware Example

// middleware.ts
export function middleware(request: NextRequest) {
  const token = request.cookies.get('token')
  if (!token) {
    return NextResponse.redirect(new URL('/login', request.url))
  }
}

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

deployment

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

data-fetching

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

app-router

No summary provided by upstream source.

Repository SourceNeeds Review