Skip to content
Latchkey

Next.js App Router route handler "No HTTP methods exported" / static error in CI

An App Router route.ts must export functions named after HTTP methods (GET, POST, and so on). A missing or misnamed export, or a static route that reads the request, fails the build or returns 405 at runtime.

What this error means

next build warns or errors that a route handler has "no HTTP methods exported", or the route fails to prerender because it reads the request or dynamic data while configured static.

next build
Failed to compile.

app/api/users/route.ts
Route handlers must export at least one HTTP method (GET, POST, PUT, PATCH,
DELETE, HEAD, OPTIONS). No HTTP methods exported.

Common causes

The handler does not export a named HTTP method

A route.ts with a default export, or a lowercase/misnamed function, provides no method the router recognizes.

A static route handler reads request data

Using the request object or dynamic functions forces the handler dynamic; if configured for static export it cannot be generated.

How to fix it

Export uppercase HTTP method functions

  1. Rename the handler to a named export matching the method, like GET or POST.
  2. Return a Response (or NextResponse) from it.
  3. Re-run next build.
app/api/users/route.ts
export async function GET() {
  return Response.json({ ok: true })
}

Mark request-reading handlers dynamic

If the handler reads the request, declare it dynamic so Next does not try to render it statically.

app/api/users/route.ts
export const dynamic = 'force-dynamic'

How to prevent it

  • Export uppercase method functions from every route.ts.
  • Return a Response from each handler.
  • Mark request-dependent handlers dynamic explicitly.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →