Design the web front end of a travel booking site for stays, like Airbnb.
Main journeys:
Constraints:
Focus on the client: architecture, state (especially URL state and dates), APIs, map + list sync, and the booking flow's correctness.
A stays marketplace combines three hard front-end problems: a search page whose state is mostly in the URL and partly in a map, date handling across time zones, and a booking flow that must be correct under concurrency (two people trying to book the same nights). Say early that these are where you'll spend your time.
| Concern | Target |
|---|---|
| Results LCP | < 2.5 s p75 mobile; first card photo is the LCP element |
| Map interaction | 60 fps pan/zoom; results refresh < 800 ms after the map stops moving |
| INP | < 200 ms for filters, date picks, marker clicks |
| SEO | city/region landing pages and listing pages server-rendered and indexable |
| Correctness | displayed total equals charged total; no double booking (server-enforced) |
| i18n | 60+ locales, 40+ currencies, RTL |
| Accessibility | WCAG 2.2 AA, including the date picker and map alternatives |
Host tools (calendar management, pricing), messaging, experiences, search ranking and pricing algorithms.
| Route | Strategy |
|---|---|
/s/:place/homes?checkin&checkout&adults&... | SSR (first page of results + map placeholder), CDN cache when no dates are set, hydrate; client-side updates afterwards |
/rooms/:id | SSR; static parts cached; availability, price and calendar fetched client-side (date-dependent) |
/book/:id?... | CSR/SSR private, no caching, minimal third-party scripts |
Landing pages (/paris) | statically generated, revalidated daily |
The map is client-only and heavy (map SDK + WebGL). Render the list first, show a static map image or a placeholder, then load the map library on idle or when the map pane becomes visible (on mobile it's behind a "Map" toggle, so it may never load). This alone can save 200–500 KB of JS from the critical path.
<SearchPage>
<SearchBar> // location combobox, date range picker, guests popover
<FilterBar /> // chips + "Filters" dialog
<SplitLayout>
<ResultsPane>
<ResultsHeader /> // "300+ stays in Lisbon", sort
<ListingGrid>
<ListingCard /> // carousel, wishlist heart, rating, price
<Pagination />
<MapPane> // lazy
<MapView /> // provider adapter
<PriceMarker /> // clustered at low zoom
<MapListingPreview /> // card popup on marker click
<SearchAsIMoveToggle />
<MobileMapToggle />
setBounds, setMarkers, onIdle,
highlight(id)) so we can switch providers and test without WebGL.hoveredListingId / selectedListingId, outside React context
to avoid re-rendering the whole tree on every hover./s/Lisbon--Portugal/homes?checkin=2025-07-10&checkout=2025-07-14&adults=2&children=1
&price_min=80&price_max=250&amenities=wifi,kitchen&room_type=entire_home
&ne_lat=38.75&ne_lng=-9.10&sw_lat=38.69&sw_lng=-9.20&zoom=13&cursor=...
Everything that changes the result set lives in the URL: shareable links, back/forward, SSR, analytics. UI-only state
(hovered card, open popovers, carousel index) stays in memory. Use replaceState for map moves (don't flood history
with every pan) and pushState for deliberate changes (new destination, dates, filters).
Check-in "10 July" means 10 July in the listing's location, regardless of where the guest is. Represent stay dates
as YYYY-MM-DD strings (or Temporal.PlainDate where available / polyfilled), never as Date objects at midnight
UTC — a new Date('2025-07-10') parsed as UTC midnight displays as 9 July for a user in New York. Times like
"check-in after 15:00" are local wall-clock times in the listing's time zone (stored as HH:mm + IANA zone).
type ID = string;
type PlainDate = string; // "2025-07-10"
type Money = { amount: string; currency: string };
interface SearchParams {
placeId?: ID;
bounds?: { ne: [number, number]; sw: [number, number] };
checkin?: PlainDate;
checkout?: PlainDate;
guests: { adults: number; children: number; infants: number; pets: number };
filters: { priceMin?: number; priceMax?: number; roomTypes: string[]; amenities: string[]; instantBook?: boolean };
sort: 'recommended' | 'price_asc' | 'rating';
cursor?: string;
}
interface ListingSummary {
id: ID;
title: string;
coordinates: { lat: number; lng: number }; // fuzzed/approximate until booked
photos: { url: string; width: number; height: number; alt: string }[];
rating?: { average: number; count: number };
displayPrice: { total?: Money; perNight: Money; nights?: number }; // total when dates are known
badges: ('superhost' | 'guest_favourite' | 'instant_book')[];
}
interface Availability {
listingId: ID;
timeZone: string; // "Europe/Lisbon"
days: Record<PlainDate, { available: boolean; checkinAllowed: boolean; checkoutAllowed: boolean; minNights: number; price?: Money }>;
fetchedAt: string;
}
interface Quote {
quoteId: ID; // server-signed; expires
listingId: ID;
checkin: PlainDate;
checkout: PlainDate;
guests: SearchParams['guests'];
lineItems: { type: 'nightly' | 'cleaning' | 'service' | 'tax' | 'discount'; label: string; amount: Money }[];
total: Money;
expiresAt: string;
}
interface ClientStore {
listings: Record<ID, ListingSummary>; // normalized; shared by list, map and wishlist
searchResults: Record<string, { ids: ID[]; total: number; nextCursor?: string }>; // key = serialized params
hoveredListingId: ID | null;
selectedListingId: ID | null;
wishlistIds: Set<ID>;
}
GET /api/search/stays?ne=38.75,-9.10&sw=38.69,-9.20&checkin=2025-07-10&checkout=2025-07-14&adults=2&children=1&amenities=wifi,kitchen¤cy=EUR&locale=pt-PT&limit=18
{
"results": [
{ "id": "l_771", "title": "Sunny loft in Alfama", "coordinates": { "lat": 38.712, "lng": -9.129 },
"photos": [{ "url": "https://img.example.com/l_771/1_720.webp", "width": 720, "height": 480, "alt": "Living room with river view" }],
"rating": { "average": 4.92, "count": 211 },
"displayPrice": { "total": { "amount": "642.00", "currency": "EUR" }, "perNight": { "amount": "160.50", "currency": "EUR" }, "nights": 4 },
"badges": ["superhost"] }
],
"mapMarkers": [{ "id": "l_771", "lat": 38.712, "lng": -9.129, "label": "€643" }],
"totalApprox": 312,
"nextCursor": "eyJvIjoxOH0",
"searchId": "srch_5521"
}
mapMarkers can include more listings than the page (e.g. top 100 in view) so the map is populated while the
list paginates.GET /api/listings/l_771 -> static details (cacheable)
GET /api/listings/l_771/availability?from=2025-07-01&months=3 -> Availability
POST /api/quotes { "listingId": "l_771", "checkin": "2025-07-10", "checkout": "2025-07-14", "guests": { "adults": 2, "children": 1 }, "currency": "EUR" }
-> 200 Quote
-> 422 { "error": "min_nights", "minNights": 5 }
The calendar fetches 3 months at a time and prefetches the next window when the user navigates months.
POST /api/reservations
Idempotency-Key: 0f7c1e...
{ "quoteId": "q_9e1", "paymentToken": "tok_psp_123", "messageToHost": "Hi! Arriving late", "agreedToRules": true }
-> 201 { "reservationId": "r_44", "status": "confirmed" | "pending_host_approval" }
-> 409 { "error": "dates_unavailable" }
-> 409 { "error": "quote_expired", "newQuote": { ... } }
-> 402 { "error": "payment_requires_action", "clientSecret": "..." } // 3-D Secure
The server enforces exclusivity (a transactional check or a short hold on the dates when checkout starts). The client's job is to make the outcome clear: if the dates are gone, show alternatives; if the price changed, show the new quote and ask for confirmation. The quote id ties what the user saw to what is charged.
interface DateRangePickerProps {
value: { start: PlainDate | null; end: PlainDate | null };
onChange: (v: { start: PlainDate | null; end: PlainDate | null }) => void;
isDateUnavailable?: (d: PlainDate) => boolean;
getMinNights?: (start: PlainDate) => number;
months?: 1 | 2; // 2 on desktop, 1 scrolling on mobile
locale: string;
firstDayOfWeek?: 0 | 1 | 6; // from locale data
}
interface MapViewProps {
markers: { id: ID; lat: number; lng: number; label: string }[];
highlightedId: ID | null;
selectedId: ID | null;
initialBounds: { ne: [number, number]; sw: [number, number] };
onBoundsIdle: (bounds: { ne: [number, number]; sw: [number, number] }, zoom: number) => void;
onMarkerSelect: (id: ID) => void;
}
interface ListingCardProps {
listingId: ID;
priority?: boolean;
onHover?: (id: ID | null) => void;
}
moveend/idle), not on every move event, with a ~300 ms debounce; abort the previous
request. Provide a "Search as I move the map" toggle — some users want to explore without the list changing.fitBounds.pointerenter sets hoveredListingId in a small external store (useSyncExternalStore);
only the affected marker and card re-render. Don't put hover state in a top-level context.minNights disabled
with an explanation tooltip ("Minimum stay is 3 nights"); checkout-only days styled distinctly.aria-label="Thursday, 10 July 2025, available", arrow keys move by day,
Page Up/Down by month, Home/End for week start/end (APG date picker dialog pattern); announce selected range.Intl.DateTimeFormat; Arabic and Hebrew calendars
render RTL with mirrored arrows.fetchpriority="high" on the very first), others lazy; load the second photo when the user hovers/swipes.
Fixed aspect ratio boxes prevent CLS.sessionStorage so an accidental reload doesn't lose the message to the
host.<dialog> with focus management; the results count in the "Show 120 places" button updates via a
live region.Intl.NumberFormat. Make clear when the charge currency
differs (host's currency) — legal and trust issue.lang attribute set on
the description so screen readers use the correct voice.hreflang alternates per locale; LodgingBusiness/VacationRental-style structured data where appropriate.HttpOnly session cookies; CSRF protection.TZ=Pacific/Kiritimati and TZ=America/Los_Angeles) to catch off-by-one dates.PlainDate) and lint rules banning new Date(string) in booking code.How do you avoid an infinite loop between map moves and search? Only re-search on user-initiated idle events; flag programmatic camera changes; compare new bounds to the last searched bounds with a tolerance.
Why are dates strings and not Date objects? A stay date has no time or zone; Date is an instant and shifts across
time zones. Plain-date strings (or Temporal.PlainDate) are unambiguous and sort lexicographically.
What happens if two users book the same dates? The server's reservation transaction (or hold) admits one; the
other gets 409 dates_unavailable. The UI apologises and shows nearby dates or similar listings.
How would you implement "flexible dates"? A different search mode: parameters like month=2025-07&nights=2-3; the
API returns the best date range per listing; cards show the dates found.
How do you keep the results page fast on mobile with a map? Default to list view, load the map only on toggle, render markers as a GL layer, and reuse the map instance across searches.
Spotted a mistake or a rights concern? Report an issue