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.
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
- Rename the handler to a named export matching the method, like
GETorPOST. - Return a
Response(orNextResponse) from it. - Re-run next build.
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.
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.