Lesson 3.2

Form validation and progressive enhancement

Client-side validation is a convenience for the user.

14mIntermediate11.4k students

Overview

Validate where it counts, enhance where it helps

Client-side validation is a convenience for the user. Server-side validation is the one that protects your data, because the client one can simply be skipped. Parse the submitted form data against a schema at the top of the action and return structured errors when it fails.

Because a form wired to a Server Action submits as an ordinary HTML form, it works before the page has hydrated. That is real progressive enhancement rather than a slogan: a slow connection degrades to a full page submit instead of a dead button.

Pending state comes from the framework hooks rather than from your own state variable, which keeps it correct when a submission is interrupted or replayed.

In this lesson you will:

  • Validate on the server and return field errors
  • Keep the form working before JavaScript loads
  • Show pending state during submission

Resources

Previous Lesson
Next Lesson
Form validation and progressive enhancement — Next.js for Production — Vertex