Choosing the Node Runtime for Amplify APIs in Next.js 16 Route Handlers
Use small Node Route Handlers around Amplify services instead of assuming Edge APIs will work on Amplify Hosting.
Amplify server libraries belong in a runtime that supports their Node dependencies. I make each Route Handler a small adapter around one application service and leave request identity inside the handler call. Hosted tests cover cold execution, malformed input, denial, and provider timeout. A successful local Edge build cannot override Amplify Hosting's documented limit on Edge API Routes. The runtime decision stays beside the handler's dependency review and response limits.
Choose the runtime from the dependency
Amplify server libraries and AWS SDK clients expect Node capabilities. I keep those handlers in the Node runtime and avoid importing them into Edge code. The AWS Amplify Hosting Next.js support page lists Edge API Routes as unsupported and documents managed SSR support through Next.js 15.
A runtime label cannot make an incompatible dependency portable. Hosted Next.js 16 behavior remains a project-level compatibility test.
Keep the handler thin
The Route Handler parses the request, resolves identity, calls one application service, and maps the result to an HTTP response. Business rules live in a testable server module. This keeps Next.js request details away from the Amplify mutation logic.
The Next.js Route Handlers guide defines the current App Router API. I use Web Request and Response types without wrapping every operation in a custom transport layer.
Bound input and execution
I reject unsupported methods and content types before reading a body. JSON and text inputs receive size limits, schemas, and timeouts. A handler that calls an external provider also uses an abort signal so the server does not wait until the platform kills the request.
Error responses distinguish validation, authentication, conflict, and dependency failure. They omit stack traces and provider payloads.
Do not buffer large files
Amplify Hosting lists Next.js streaming as unsupported, so I do not depend on a streamed Route Handler download there. I return a bounded response or redirect to a scoped, signed Storage URL. Any server-mediated response-streaming path remains a canary until the host documentation supports it.
The Amplify SSR supported-features guide documents host limits and supported Node versions. I test files near the application's allowed size instead of using a tiny fixture.
Separate module setup from request state
A server module may reuse an SDK client configuration, but request cookies, user identity, and mutable buffers stay inside the handler call. Global request state can leak between warm invocations.
I attach a generated request ID and safe operation name to logs. Tokens, record bodies, and private storage keys do not become default fields.
Test under hosted compute
I run the handler locally and on an Amplify branch. The hosted check covers a cold request, malformed input, a denied identity, provider timeout, and a successful response. I compare memory and duration through CloudWatch logs where available.
My Amplify and Vercel comparison gives the wider hosting context for runtime ownership and recovery.
Need a Route Handler runtime review?
I can review Node dependencies, request-state isolation, timeouts, and the hosted response path for an Amplify-backed handler. Send sanitized errors through the contact page, or see my AWS development services.