Next.jsInterview preparation
Intermediate·Concept·2 min read

Route handler vs Server Action vs middleware/Proxy?

Practice this question

Definition:

Route handlers expose HTTP endpoints, Server Actions provide server-side functions for mutations, and middleware/Proxy can intercept requests for routing behavior. They are different entry points with different responsibilities. An action or handler exposed through the app must still validate input and enforce access near the protected work.

Key points:

  • Route handler: an HTTP endpoint. Server Action: a server function used for mutations.
  • Middleware is called Proxy in Next.js 16; it can handle request redirects or rewrites.
  • Check permissions inside protected handlers and actions, close to the data access.

Reference: Next.js Proxy.

  • Proxy is the Next.js 16 name for middleware; do not move all authorization into redirects at the edge of the application.

Interview point:

  • A hidden button or a server-only function location is not sufficient authorization for a callable mutation.
Adapted from 06_REACT_NEXTJS.md · “Route handler vs Server Action vs middleware/Proxy?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.