Question presented to candidate: "Build a signup form with Server Actions. How does it behave before the JavaScript has loaded, and how do you show validation errors and a pending state?"
What a strong answer should cover:
- Pass the action to
<form action={...}>; the action receives aFormData. - The server-rendered HTML is a real multipart POST form with a hidden action id, so it submits even before or without JavaScript.
- After hydration React intercepts the submit, calls the action without a page reload, and keeps client state.
useActionStatereturns the action result (such as validation errors) and a pending flag;useFormStatusgives pending state to a submit button.- Validate on the server in the action; client-side validation is a convenience, not a guarantee.
Clarifying questions expected:
- "Must it work without JavaScript?" β then errors must come back through the action result, not client-only state.
- "Where should the user go after success?" β
redirect()inside the action.
Code / implementation expected: Yes β a form with useActionState and a pending button.