Next.js Curriculum

Server Actions & Form Mutations

Server Actions expose transparent RPC endpoints powered by the "use server" directive, enabling full-stack mutations without manual API controllers.Learn how to handle GET search/filter navigation forms using next/form alongside POST mutation forms using React 19 useActionState and useFormStatus.Deliver instantaneous user feedback using useOptimistic, enforce progressive enhancement for JavaScript-disabled environments, and manage post-mutation cache revalidation.

Lesson 01Medium30 min

Server Actions Fundamentals & RPC Execution Model

Server Actions are asynchronous server functions defined with the "use server" directive. They implement a type-safe Remote Procedure Call (RPC) protocol over HTTP POST requests. Next.js automatically creates internal POST endpoints, serializes arguments, executes the action on the server, revalidates cache segments, and returns the updated RSC Flight payload in a single network roundtrip.

Lesson 02Medium30 min

Form Architecture: GET Navigation (next/form) vs POST (useActionState)

In modern Next.js form architecture: use next/form for GET search and navigation forms to automatically update the URL query parameters with client-side soft navigation and prefetching. For POST data mutations, use standard <form> coupled with React 19’s useActionState hook from "react" to manage pending state, returned errors, and optimistic updates without boilerplate.

Lesson 03Hard35 min

Optimistic UI Updates with useOptimistic

useOptimistic is a React 19 hook that renders predicted mutation outcomes immediately in the UI before server confirmation. If the server action succeeds, the optimistic state is replaced seamlessly by the fresh server state. If the action fails or rejects, React automatically rolls back the UI to the prior confirmed state without manual compensation code.

Lesson 04Medium25 min

Progressive Enhancement & JavaScript-Disabled Forms

Progressive enhancement ensures that web applications remain fully functional even when client-side JavaScript is disabled, blocked by ad-blockers, or still downloading. Next.js Server Actions achieve this by leveraging standard HTML <form action={action}> semantics: without JavaScript, the browser performs a native multi-part POST request; with JavaScript, it upgrades to an asynchronous Flight RPC call.

Lesson 05Medium30 min

Server Action Closures, Revalidation, and Redirection

Server Actions can close over server-side scope and receive bound parameters via Function.prototype.bind. After executing mutations, Server Actions orchestrate data updates through revalidatePath/revalidateTag and page navigation via redirect(). Critically, redirect() internally throws a NEXT_REDIRECT exception that must not be caught by unhandled try/catch blocks.