Skip to content
Learn Netverks

Lesson

Step 25/36 69% through track

forms-mutations

Forms and mutations

Last reviewed May 28, 2026 Content v20260528
Track mode
client_nextjs
Means
In-browser Next.js (client components)
Reading
~1 min
Level
intermediate

This lesson

This lesson teaches Forms and mutations: the concepts, APIs, and habits you need before advancing in Next.js.

Forms are where UX and validation meet—controlled inputs are the React default for predictable state.

You will apply Forms and mutations in contexts like: Login flows, settings panels, checkout steps, and admin CRUD screens.

Write TSX for Client Components, click Run—React 18 CDN + in-browser TSX compile; use client/server lessons explain App Router concepts; mountApp renders interactive UI; printOutput feeds the terminal.

When you can explain the previous lesson's ideas without copying starter code.

Next.js forms combine HTML semantics, Server Actions, and optional client validation. The goal: reliable mutations with clear pending and error states.

Pending state with useFormStatus

'use client';
import { useFormStatus } from 'react-dom';

function SubmitButton() {
  const { pending } = useFormStatus();
  return <button disabled={pending}>{pending ? 'Saving…' : 'Save'}</button>;
}

Client + server validation

  • Client: instant feedback (required fields, format)
  • Server: authoritative checks (permissions, uniqueness, sanitization)

Controlled inputs in Client Components

Rich widgets (tag pickers, WYSIWYG) stay client-controlled; submit through a Server Action or hidden fields synced before submit.

Self-check

  1. Why validate on both client and server?
  2. What does useFormStatus require parent-wise?

Challenge

Form submit sim

  1. Type a todo title and submit.
  2. Confirm pending then success states.
  3. Try empty submit and see validation.

Done when: form shows pending, success, or validation error.

Tip: useFormStatus must sit inside a component that is a child of <form action={...}>—not in the same component that owns the form.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • useFormStatus pattern?
  • Validation layer?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump