Loading Depth Study
Preparing your workspace
Route handlers provide server-side HTTP endpoints inside a Next.js application.
Next.js can handle HTTP requests directly through route handlers in the app directory. These endpoints can accept GET, POST, PUT, PATCH, DELETE, and other supported methods. Route handlers are useful for application APIs, webhooks, server integrations, or endpoints that need custom HTTP behavior. Sensitive logic should remain server-side, and handlers still need validation, authentication, authorization, consistent errors, and safe database access.
A Next.js learning platform can expose /api/courses, /api/progress, and /api/webhooks/payment from the same application.
import { NextResponse } from 'next/server';
export async function GET() {
return NextResponse.json({
status: 'ok'
});
}A GET request to the route returns a JSON health response.