Server Actions vs API Routes vs Route Handlers in Next.js
The difference between Server Actions, Route Handlers, and API Routes, and which one to use for forms, webhooks, and external APIs.
Full-stack React framework
The difference between Server Actions, Route Handlers, and API Routes, and which one to use for forms, webhooks, and external APIs.
How to redirect after a Server Action with the redirect function, and why the order of revalidation, try/catch, and push vs replace matters.
How to use the useOptimistic hook to show instant UI while a Server Action runs, and how it reverts when the action fails.
How to call a Server Action from onClick or useEffect, wrapped in useTransition, and why the pending flag depends on it.
The mechanics behind Server Actions: action references, POST requests, sequential dispatch, the single-roundtrip response, and the security boundary.
Why every Server Action must re-check authentication, ownership, and input, and what the framework already protects on its own.
The most common reasons a Next.js Server Action appears to do nothing, and how to make the mutation or the refresh actually happen.
Build a Next.js form that submits to a Server Action: bind the action, read FormData, validate on the server, and show the returned result.
How the Form component from next/form prefetches loading UI, navigates on submit, and handles search params, plus when to use a native form instead.
Return fieldErrors from a Server Action and render each message under its input with aria-describedby, so errors are visible and announced.
How the Next.js Metadata API works in the App Router: the static metadata object, the dynamic generateMetadata function, how segments merge, and what actually lands in the rendered head.
How to write Open Graph and Twitter card metadata in the Next.js App Router: the openGraph and twitter fields, automatic card defaults, article tags, and image merge rules.