Build a booking widget with live pricing
I was asked this
No reports yet. Sign in to say where you were asked it.
A coding interview question asked in Airbnb's coding round, last asked Aug 2025. It tests frontend, react and apis.
Build a small reservation widget for one listing, with a front end and a simple back end. The guest picks check-in and check-out dates and the number of adults and children, sees the total price update as they change them, and books. The price depends on the dates and the guest count. The Book button is disabled when the listing can't take the stay, and a confirmation dialog appears after booking.
Interface
Unless you agree on a different interface with the interviewer, assume:
-
GET /listings/{id}/quote?check_in=YYYY-MM-DD&check_out=YYYY-MM-DD&adults=N&children=N→{available: bool, nights: int, nightly: [{date, price}], fees: {...}, total: int, currency: str}. Prices in minor units (cents). -
POST /listings/{id}/reservations {check_in, check_out, adults, children, quote_total, idempotency_key}→201 {reservation_id}, or409when the dates are no longer free or the price changed. - A
BookingWidgetcomponent with date inputs, guest steppers, the price breakdown, a Book button and a confirmation dialog.
Example
Assume a nightly rate of $120, an extra-guest fee of $15 a night for each guest beyond two, and a maximum of 4 guests.
check_in 2026-11-06, check_out 2026-11-09, 2 adults, 1 child
-> 3 nights × ($120 + $15) = $405, Book enabled
5 guests -> Book disabled: "This place fits up to 4 guests"
dates overlapping a booking -> Book disabled: "Those dates are taken"
Constraints
- Check-out must be after check-in; dates in the past are rejected.
- The server is the source of truth for the price and availability; the client total is only a preview.
Clarifying questions
- Do children count toward the guest limit and the extra-guest fee?
- Do prices vary by night (weekends, seasons), and are there cleaning or service fees?
- Should the quote refresh on every change, or after the guest stops changing inputs?
- What happens if the price changes between the quote and the booking?
- Which frameworks may I use?
What a strong answer covers
- Component state split into inputs (dates, guests) and server data (quote, loading, error), with the price recomputed from the server's quote.
- Debouncing quote requests and cancelling stale ones so an old response never overwrites a newer one.
- Clear disabled states with a reason, loading feedback, and errors shown in place.
- Booking that is safe to retry (an idempotency key) and re-checks availability on the server inside a transaction, so two guests can't book the same nights.
- Accessible date and number inputs; a dialog that traps focus and can be closed with the keyboard.
- Tests: the price for a few date and guest combinations, the disabled states, a double-clicked Book button.
Follow-ups
- Show prices in several currencies. Where does conversion happen, front end or back end, and how is the rate fixed at booking time?
- The page makes too many requests. How would you cut them down (debouncing, caching quotes, batching availability for a month)?
- Make a guest's reservation viewable offline: what you would cache in the browser (IndexedDB, a service worker), how you would keep it in sync after reconnecting, and how you would protect personal data cached on the device (minimal data, encryption at rest, token lifetimes, XSS and CSRF).
Where it's asked
- Airbnb · Coding · Last asked Aug 202545 min · Live coding, one or two rounds, from the same pool as the screen
What it tests
frontend · react · apis · full stack
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
