LESSON 05 / 9·2 min readIntermediate

Route handler vs Server Action vs middleware/Proxy?

Try code in the playground
01 Understand02 Recall03 Prepare

Understand the concept

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.

Important ideas

  • 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.
PAUSE & RECALL

Can you explain it without the notes?

Route handler vs Server Action vs middleware/Proxy?

Use your own words. Explain an example and one limitation before checking the explanation.

Check your explanation

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.

CONNECT IT TO YOUR INTERVIEW

Turn this concept into a clear answer.

  • A hidden button or a server-only function location is not sufficient authorization for a callable mutation.
Practice this concept
YOUR NEXT STEP

Keep connecting the ideas.

Next lesson: How should caching and revalidation work?

Adapted from 06_REACT_NEXTJS.md · “Route handler vs Server Action vs middleware/Proxy?”. Examples are study fragments; framework behavior can depend on your version.