Next.js 15.2 introduced a Create Next App option for starting with an API-only app, with no pages or UI components. Lee describes good fits such as exposing a data layer to multiple clients, proxying requests to a backend that requires secrets, handling webhooks, and keeping authentication logic on the server.
Building APIs with Next.js
Lee Robinson (leerob), a Next.js developer at Vercel, explains how to build and deploy APIs with Next.js; no other speakers are identified.
A `route.ts` file in the App Router defines an endpoint, and its location determines the URL; nesting it under `app/api/users` creates `/api/users`. Export named functions such as `GET`, `POST`, `PATCH`, or `DELETE` to handle those methods, using the standard Web Request and Response APIs. Dynamic segments such as `/api/users/[id]` provide route parameters, which Next.js 15 requires awaiting.
Next.js provides utilities for reading request data such as cookies, headers, and URL search parameters. Lee also demonstrates a `withAuth` helper that checks for a token in cookies, returns a 401 response when it is missing, and wraps a named route handler such as `GET`. He recommends considering direct calls to shared server-side functions when a separate network endpoint is unnecessary.
A Node.js server or Docker host can run dynamic APIs and other Next.js server features. Static export can serve route handlers that are pre-rendered at build time, but those responses do not vary with each request. Lee also discusses deploying on Vercel, including Fluid Compute, and mentions platform features for rate limiting and cron jobs.
Lee says Next.js offers flexible route handlers, but backend-focused frameworks may suit teams that need specialized API features. He describes Server Actions as POST-like operations that Next.js invokes without requiring a public `/api` URL, and says a shared data-layer function can serve both an action and a public endpoint. TypeScript is supported, and client-side tools such as SWR can call route handlers.
Takeaways
- Use Next.js route handlers when a frontend app needs an API for multiple clients, a secure backend proxy, webhooks, or server-side authentication.
- Put HTTP methods for one resource in the same `route.ts` file and export each method by its HTTP verb.
- Keep database and business logic in reusable server-side functions so route handlers, Server Actions, and Server Components can share it.
- Choose dynamic hosting for request-specific API responses; static export only supports responses fixed at build time.
- Use a direct server-side function call when a Server Component needs data and no separate API endpoint is needed.
Mentioned in this talk
Search inside this talk
What was claimed 11
- featureCreate Next App: Provides a simplified API-only app starting point with no pages or UI components.
“lets you build a new app that’s API-only”
YouTube Unverified1 source· Talk
- featureApp Router: Uses Web Request and Response APIs for route handlers.
“in the App Router, we changed to use the Web APIs”
YouTube Unverified1 source· Talk
- featurePages Router: Its API routes use Node.js request and response objects.
“These were built on the Node.js request and response objects”
YouTube Unverified1 source· Talk
- feature
Next.js: Can serve as a proxy or forwarding layer to an existing backend API.
“you just need to make a request through the Next.js server to go to this other location”
YouTube Unverified1 source· Talk
- feature
Next.js: Can use shared helper logic to apply authentication checks around route handlers.
“wrap the other parts of your APIs”
YouTube Unverified1 source· Talk
- feature
Next.js: Can run with APIs on Node.js hosting or Docker-compatible hosting.
“if you deploy it to Node.js hosting or anywhere that supports a Docker container, you have the ability to use all server features, including APIs”
YouTube Unverified1 source· Talk
- feature
Next.js: Route handlers in static export mode can provide APIs with content pre-rendered during the build.
“route handlers can still be used like APIs in static export mode”
YouTube Unverified1 source· Talk
- feature
Vercel: Offers Fluid Compute for API and backend applications, with pre-warmed instances to avoid cold starts.
“we keep a pre-warmed instance so you don’t have cold starts”
YouTube Unverified1 source· Talk
- feature
Vercel: Firewall offers programmatic rate limiting, and the platform supports cron jobs.
“the Vercel Firewall offers programmatic rate limiting, and we have cron jobs on the platform too”
YouTube Unverified1 source· Talk
- feature
Next.js: Route handlers can define multiple HTTP methods, use dynamic paths, and return web-standard responses.
“You can do a bunch of different HTTP methods inside the same file, use dynamic paths, and access web-standard APIs like Request and Response.”
YouTube Unverified1 source· Talk
- featureServer Actions: Act like autogenerated POST APIs, with Next.js handling navigation to the route and encrypting the value.
“You can think about Server Actions like an autogenerated POST API”
YouTube Unverified1 source· Talk








