Skip to content

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
Practice it live

Your first interview starts free.

You choose 5, 20 or 45 minutes before you start.

See the question brief and its sources
On this page
Asked at

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

AskWhy it mattersA 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.

The requirements menu

RequirementScopeWhy

Walk through several pages of questions, forward and back, with progress shown

Core

The shape of the flow. Progress shown is what tells someone how much is left, and a page split by topic keeps each screen short.

Keep answers across pages, reloads and a break of hours

Core

Losing answers on Back or a reload is the first thing that goes wrong in a naive build, and one interview guide calls it the most common trap set on this question.

Check each field as the person goes, and again on the server

Core

Errors found on the page they belong to are cheap to fix; errors found at the end send someone back across the whole flow. The server check is for trust, since the browser can be bypassed.

Review everything, then submit once, even if the button is pressed twice or the network drops

Core

The last press creates an account. A review page lets people catch mistakes first, and the submit must be safe to repeat.

Show pages that depend on earlier answers, such as the type of business

Core

In this design, the sign-up branches on the kind of business. It decides how the progress indicator counts and what happens when an earlier answer changes.

Jump back to a completed page from the progress list

Optional

Take it if there is time: it fits the review page and lets people check earlier answers in place. Leave it if the path branches heavily, since a change on an early page can remove later ones.

Warn before leaving the tab with answers not yet saved

Optional

Take it if the save to the server lags behind the page. With a save on each page change and a copy per tab, the window is small, and a leave prompt annoys people.

Offer an answer already given, such as the same address as the business address

Optional

Take it: it meets the redundant-entry rule in the non-functional list with little code, a checkbox or a prefilled field. Leave it for fields where re-entry is a deliberate check.

Check a field against the server as it is typed, such as whether an email is already registered

Optional

Take it where a rule that needs the server would otherwise surface late. Leave it where the check is slow: a pending Next button is better than a field that flickers.

Finish the sign-up on another device

Optional

Take it when asked. It needs the draft on the server plus a way to find it again, a link or a sign-in, and a decision about which sensitive answers are re-asked.

Build each page from rules the server sends

Out of scope

A form engine is a project of its own. For 5 to 7 pages, defining the pages in the client is less code and easier to test.

Checking a person's identity documents

Out of scope

A separate service with its own flow. The sign-up hands over what it collected.

Choosing a pricing plan

Out of scope

A product decision that may change often; it belongs after the account exists.

Translations into other languages

Out of scope

Strings as data is good practice, but the language work itself is not part of this round.

Non-functional requirements

RequirementWhat 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

EntityWhat 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

EndpointNotes

POST /applications → { id, version }

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.

GET /applications/{id} → { answers, current_page, version }

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.

PATCH /applications/{id} { page, answers, version } → { version, errors }

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.

POST /applications/{id}/submit with an Idempotency-Key header → { status, account_id }

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.

GET /applications/{id}/submission → { status, account_id }

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

submitanswersCurrent pageFlow storeApplication server

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.

loadrenderfocus, titleNexterrorsvalidcopysave, versionsubmit, keyfield errorsopen, focustimeoutPage in addressPage routerCurrent pageHeading and titleShared rulesError summaryFlow storeSession storageApplication serverDraftsResults by keyError to page andfieldStatus check
The whole design

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.

A concept that helps here: Idempotency keysA concept that helps here: Sync queues and client idempotencyA concept that helps here: Core Web Vitals

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.

A concept that helps here: Where state livesA concept that helps here: Coordinating across tabsA concept that helps here: Conflict resolution on the client

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.

A concept that helps here: Form validationA concept that helps here: Partial failure in the UI

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.

A concept that helps here: Accessible widgets

Concepts this guide uses

Sources

  1. techinterview.org: Build a multi-step form wizard
  2. WAI tutorial: Multi-page forms
  3. WAI tutorial: User notification in forms
  4. WCAG 2.2 Understanding: Timeouts (2.2.6)
  5. WCAG 2.2 Understanding: Redundant Entry (3.3.7)
  6. WCAG 2.2 Understanding: Error Prevention (Legal, Financial, Data)
  7. Stripe docs: Advanced error handling
  8. MDN: Window.sessionStorage
  9. MDN: Client-side form validation
  10. MDN: Using HTML form validation and the Constraint Validation API
  11. MDN: History.replaceState()
  12. MDN: ARIA live regions
  13. MDN: ARIA aria-invalid attribute
  14. web.dev: Web Vitals
Sign in to report a mistake