@openseat/cloud
v0.1.0
Published
Browser client for the OpenSeat Cloud API: live seat maps, hold tokens and browser holds with your publishable key, plus OpenSeatBookingMap for React (hold or select mode, seats and standing zones).
Maintainers
Readme
@openseat/cloud
The OpenSeat Cloud API in the browser. Show a live seat map for your event with your publishable key, let
the buyer choose seats and standing-zone tickets, and hold them; your server then books them with
@openseat/node after payment.
- Publishable key only.
os_pk_live_…/os_pk_test_…works only from the origins you allowed. A secret key (os_sk_…) is refused before anything is sent. - Seats and zones. Numbered seats, whole tables, booths and standing or seated zones sold by quantity, in the same event or zones only.
- Two ways to hold.
holdmode: the page holds with a hold token and gives you the token.selectmode: the page only lets the buyer choose, and your server holds (server holds, keyed by your own buyer ID).
npm install @openseat/cloud
# for the React component:
npm install @openseat/react react react-dom konvareact, react-dom, konva and @openseat/react are optional peers: they are needed only for
@openseat/cloud/react. The root entry has no React code.
React: hold mode
import { OpenSeatBookingMap } from "@openseat/cloud/react";
<OpenSeatBookingMap
publicKey={pk}
baseUrl={url}
eventKey="tedx-2026"
onHeld={async (h) => {
const o = await createOrder(h.holdToken);
openRazorpay(o);
}}
/>;The buyer chooses seats (and zone quantities in a ticket picker, a bottom sheet on phones), then taps
Continue with N tickets. The page holds them and calls onHeld once per hold, with an OpenSeatHold:
interface OpenSeatHold {
holdToken: string; // send it to your server in a request body, never in a URL
holdId: string;
eventKey: string;
seatIds: readonly string[];
areas: readonly { inventoryId: string; quantity: number }[]; // zones, booths and whole tables
expiresAt: string;
locked: boolean; // true once your server attached an order
}Your server attaches the order (openseat.holds.attachOrder(holdToken, orderId), which locks the hold),
takes payment, and books it (openseat.events.book({ eventKey, holdToken, orderId })). The page sees the lock
within holdRefreshMs (default 15 s) and the booking through the live feed, and shows Booked.
While held, the page shows an m:ss countdown and Change seats (disabled once locked): the buyer picks
other seats on the map and taps it to swap the hold atomically (their old seats never become free in
between). An expired hold keeps the choice selected so one tap holds it again.
Props (besides BookingMap's display props such as theme, legend, mapHeight, rules):
| Prop | |
| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| eventKey | Your event key (the ID you created the event with). |
| publicKey + baseUrl, or client | Credentials, or a client from createOpenSeatClient. |
| mode | "hold" (default) or "select". |
| onHeld(hold) | Hold mode: seats held. A returned promise is awaited, then the hold is re-read. |
| onHoldChange(hold \| null), onHoldExpired(), onCompleted(hold), onError(e) | Lifecycle. |
| resume | "session" (default): a reload in the same tab resumes the hold. false turns it off. |
| holdRefreshMs | How often the hold is re-read while held. Default 15,000. |
| maxTickets | Per-buyer limit; beats the event's maxTicketsPerBooking (as does rules.maxTickets). |
| categoryPrices | Display prices by category; beats the event's price labels ("1499" shows as ₹1,499). |
| renderActions(flow) | Replace the default buttons, with the whole useBookingFlow result. |
| renderCheckout(ctx) | Shown under the countdown while held: { hold, remainingMs, locked, extend, release }. |
| loadingFallback, errorFallback(e) | Shown while loading, or when the event cannot be loaded. |
| onAreaSelect | Replaces the built-in zone picker (then set quantities through renderActions). |
React: select mode (your server holds)
For platforms that hold from their own server (openseat.holds.create({ eventKey, buyerRef, seatIds, areas })
in @openseat/node), so a buyer's ticket limit follows your own user ID:
<OpenSeatBookingMap
publicKey={pk}
baseUrl={url}
eventKey="tedx-2026"
mode="select"
ownHold={
serverHold && {
holdId: serverHold.holdId,
seatIds: serverHold.seats.map((s) => s.seatId),
areas: serverHold.areas.map((a) => ({ inventoryId: a.inventoryId, quantity: a.quantity })),
expiresAt: serverHold.expiresAt,
}
}
onContinue={async ({ seatIds, areas }) => {
const hold = await api.holdSeats({ eventKey: "tedx-2026", seatIds, areas }); // your backend
if (hold.ok) goToCheckout(hold);
}}
/>- Select mode never mints a hold token or sends a hold request from the page.
onContinuereceives{ seatIds, areas }in the shapeholds.createtakes: whole tables come as an area ({ inventoryId: tableId, quantity: 1 }). A returned promise keeps the button busy.ownHoldis the hold your server already made for this buyer (for example when they come back to change seats): its seats and places are shown as theirs and chosen on the map, the live feed's "held" for them is ignored, and a "Held for you" countdown runs to itsexpiresAt. Pass the new one after your server replaces it.
Without React
import { createOpenSeatClient, rememberHold, recallHold } from "@openseat/cloud";
const openseat = createOpenSeatClient({ publicKey: pk, baseUrl: "https://openseat.example.com" });
const event = await openseat.loadEvent("tedx-2026"); // { name, layout, priceLabels, saleOpen, etag, … }
const stop = openseat.watchEvent("tedx-2026", (e) => redraw(e.layout)); // only when the layout revision changes
const a = openseat.adapter; // a BookingAdapter for @openseat/booking and @openseat/react
await a.prepare("tedx-2026"); // mint the hold token early (on the buyer's first click)
const hold = await a.holdSeats({ eventId: "tedx-2026", seatIds: ["A-1"], idempotencyKey: crypto.randomUUID() });
const token = a.holdToken("tedx-2026");| Method | |
| ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| loadEvent(eventKey, { ifNoneMatch?, signal? }) | The event and its layout, or "not-modified" for a matching ETag. |
| watchEvent(eventKey, onChange) | Re-reads the event (with its ETag) when the live stream resets or reconnects; calls back only for a new layout revision. Returns a stop function. |
| adapter | Statuses (getStatuses, getAreaStatuses), live updates (subscribe, subscribeAreas), holdSeats (atomically replaces the token's hold), getHold, extendHold, releaseHold, prepare, holdToken, resetHoldToken. confirmHold is refused: book from your server. |
| resumeHold(hold) | After a reload: re-seed the token from recallHold(eventKey) and read the hold. |
| completeHold(eventKey) | Your server booked it: drop the token and the remembered hold. |
| me() | { mode, allowedOrigins, originAccepted, last4 }: "is my key working here?" |
rememberHold(hold) / recallHold(eventKey) keep one hold per event in sessionStorage (rememberHold(null)
forgets them all).
Where the hold token goes
- Only in the
OpenSeat-Hold-Tokenheader of the four hold requests (hold, read, extend, release). Never in a URL, never on reads or the live stream, never inlocalStorage, never in a log or an error message. - In memory, one per event. With
resume: "session"also in this tab'ssessionStorage, cleared on completion or expiry. A script on the page could read it there, but such a script can already read memory; and once your server attaches the order, the token can no longer change or release the hold. - The live stream URL carries the publishable key (
?key=), becauseEventSourcecannot send headers. It is not a secret.
Errors and developer messages
Every failure is a BookingError (code, reason, status, retryAfterMs, unavailableSeatIds,
unavailableAreaIds); reason is one of OpenSeatErrorReason (the same union as the server and
@openseat/node). A wrong key, an origin you have not allowed, and an SDK too old for the event's seat map
each print one console.error explaining the fix, naming the key only by its last four characters. An event
that cannot be found lists the checks: the event key, API access on, published, and the key's mode.
Reserved
@openseat/cloud/designer (the embeddable layout designer, mountDesigner and <OpenSeatDesigner>) is
reserved for the next release and not exported yet.
