How to design a multi-step form (frontend)
The first sections are free. The deep dives, level expectations and quiz are part of Pro.
Episode20 min2 parts
Two hosts talk this question through
One host leads. The other asks what you would ask.
Live practice
Practice this question out loud
Your interviewer asks this question and follows up on each choice, the way the real round goes. You talk it through and sketch it on a whiteboard. The 20 and 45 minute rounds end with a scored report.
- Spoken answers
- Follow-up questions
- Whiteboard
- Scored report
- 5 to 45 min
Your first interview starts free.
You choose 5, 20 or 45 minutes before you start.
On this page
- The problem
- Clarifying questions
- The requirements menu
- Non-functional requirements
- Core entities
- The API
- The high-level design
- What breaks first
- The deep dives
- Entity fields
- A submit that happens exactly once
- Answers kept across pages, reloads and tabs
- Field checks on the client and the server
- Using it with a keyboard and a screen reader
- Variants
- What each level is expected to show
- The 30-second answer
- Quiz
The problem
A sign-up flow for a business that wants to take payments: 5 to 7 pages of questions, answers carried across them, a check on each field, and a last press that creates an account. The answer turns on two decisions: where the answers live between pages, so that a reload, Back or a night away keeps the pages already completed, and how the last press is made safe to repeat, with a submit key derived once from the draft's id so a second press, a retry, or a second tab that opened the same draft sends the same key and gets the first result back instead of a second account.
Clarifying questions
| Ask | Why it matters | A typical answer |
|---|---|---|
How many pages are there, and do some appear or disappear depending on earlier answers? | A fixed list of pages is index math. Pages that depend on the type of business need the path recomputed when an earlier answer changes, and that changes the progress indicator and what Back means. | Say 5 to 7 pages. Some depend on earlier answers: a sole trader and a company see different pages. |
What must the answers survive: Back and Next, a reload, a closed tab, a night away, another device? | Each step up the list moves the answers further from the page: from component state, to a store, to the browser, to the server. The level you pick decides which of these events keeps the answers and which loses them. | A reload, a closed tab and a break of 20 hours on the same laptop. Finishing on another device is a stretch question, not the base. |
Which answers are sensitive enough that they should not sit in the browser? | Card and identity numbers in local or session storage are a liability worth raising yourself, and the answer changes what the draft holds. | Card and identity numbers are collected but kept out of browser storage. Checking identity documents is someone else's problem. |
Which checks can run in the browser, and which need the server? | A format rule can run on blur. A lookup such as whether a tax number exists can take seconds and belongs on the server, which decides how Next behaves while it runs. | Formats and required fields in the browser, with the same rules on the server. A tax number lookup runs on the server and can take a while. |
What does the final submit create, and can it be undone? | If the result can be rolled back, a duplicate is an annoyance. If it opens an account, a duplicate is an incident, and the submit must be safe to repeat. | It creates a payments account, which is not something to quietly delete, so a second press, a resend when the reply was lost, or a second tab must not create a second one. |
Who uses it, and with what? | Keyboard and screen reader support change how a page change is built: focus, heading, title and announcements, not a layer added later. | Businesses of all kinds, on phones and desktops, some with a keyboard and a screen reader. Translations are out of scope. |
Non-functional requirements
| Requirement | What it forces |
|---|---|
A press of Next or Submit answers within 200 milliseconds | The press itself must show something at once: a pending state on the button or the next page painted, with nothing heavy in the handler. A server save or a server check can take longer than that, so the press is acknowledged first and the network finishes later. Interaction to Next Paint, the Core Web Vital for interactivity, is the measure, and web.dev marks 200 milliseconds or less as good. |
Answers survive at least 20 hours with no activity | Answers have to leave the page and the tab. Page memory dies with a reload, session storage dies with the tab, so the draft goes to the server with an id the browser can find again, and the server keeps it past that window. |
A repeated final submit never creates a second account | A key created once per draft and kept with the draft, sent with each attempt, so the server can match a repeat to the first result. A lost reply is settled by a status query, not by sending again with a fresh key. |
Usable with a keyboard and a screen reader, each page change announced | Each page needs a heading of its own, the step at the front of the document title, focus placed on the fresh heading (or the first input) after each change, and errors tied to their fields and summarized in a live region. |
Information already given is filled in or offered rather than asked for again, unless re-entry is essential or needed for security (WCAG 2.2, 3.3.7, level A) | A later page that needs an earlier answer, such as an address, fills it in or offers it to select, which pushes toward a single store covering the flow that any page can read. |
Core entities
| Entity | What it holds |
|---|---|
Application draft | One person's answers so far, kept on the server and mirrored in the browser. |
Page definition | What one page asks and when it appears. |
Field error | One problem with one answer, from either side. |
Submission | The record of the final press and what it produced. |
The API
| Endpoint | Notes |
|---|---|
| Creates an empty draft on the first visit. The client puts the id in the address and makes the submit key at the same time, so both exist before the first answer is typed. |
| Called on load when the address has an id. The answer is the draft to render, and its version is what the next save must quote. |
| Sent when the page changes rather than per keystroke. The server checks the page's rules and returns field errors; it refuses a save whose version is behind the stored one, and the client then reloads the draft. |
| The final press. The key is the draft's submit key, the same on each attempt, so a repeat gets the stored first result rather than a second account. |
| Asked after a timeout or on return to a draft that was submitted. Tells the client whether to show success, show the failure, or offer a retry with the same key. |
The high-level design
Step 1 of 5
Pages, a store, a submit
Start with the shape the interviewer can see end to end: a current page writes its answers into a single store that covers the flow, keyed by page id, and the last page posts the lot to the server. One store rather than state inside each page component is the first choice worth saying aloud: it is what lets Back show the answers that were there. This step already has three problems: a reload empties the store, the browser's Back button leaves the flow because the page lives in component state, and a second press of Submit sends a second request.
What breaks first
The deep dives
A submit that happens exactly once. Someone on a slow connection presses Submit, sees nothing change for a few seconds, presses again, and then the connection drops. Walk through what reaches the server, what the person sees, and how many accounts exist afterwards.
Answers kept across pages, reloads and tabs. Someone fills in four pages, reloads by mistake on the fifth, closes the tab at night and opens the link the next morning on the same laptop. Walk through where the answers are at each point and what the page shows.
Field checks on the client and the server. On the review page the server rejects the tax number that was entered several pages earlier, after the person has filled in everything else. Walk through what they see, where focus lands, and what happens to the other answers.
Using it with a keyboard and a screen reader. Someone who uses a keyboard and a screen reader, and no mouse, presses Next. Walk through what they hear and where focus lands, on a page that is valid and on one with errors.
Concepts this guide uses
Sources
- techinterview.org: Build a multi-step form wizard
- WAI tutorial: Multi-page forms
- WAI tutorial: User notification in forms
- WCAG 2.2 Understanding: Timeouts (2.2.6)
- WCAG 2.2 Understanding: Redundant Entry (3.3.7)
- WCAG 2.2 Understanding: Error Prevention (Legal, Financial, Data)
- Stripe docs: Advanced error handling
- MDN: Window.sessionStorage
- MDN: Client-side form validation
- MDN: Using HTML form validation and the Constraint Validation API
- MDN: History.replaceState()
- MDN: ARIA live regions
- MDN: ARIA aria-invalid attribute
- web.dev: Web Vitals