DOM events
The widget fires whocoming:ready, whocoming:rsvp and whocoming:error on the element. They bubble and cross the Shadow DOM.
Listen on the element, or anywhere above it (every event bubbles and is composed, so it leaves the Shadow DOM):
document.addEventListener("whocoming:rsvp", (event) => {
const { rsvp_id, status } = event.detail;
console.log("RSVP", rsvp_id, status);
});event.target is the <whocoming-rsvp> element that fired it, which tells you which event it was when a page has several.
whocoming:ready
The event loaded and the card is showing. Fired once per event ID.
detail: {
event: string; // "evt_demo0000000000000001"
state: "open" | "full_waitlist" | "full" | "ended" | "cancelled";
}whocoming:rsvp
A guest sent the form and the RSVP was saved.
detail: {
rsvp_id: string; // "rsvp_..."
status: "going" | "waitlisted";
}This is the browser-side signal, good for analytics and thank-you messages. For anything that must not be missed (adding a guest to your CRM, for example), use the rsvp.created webhook, which is retried until your server confirms it.
whocoming:error
Something went wrong. The widget already shows the guest a message; this is for your logs.
detail: {
code: string;
}code is one of the API's error codes (such as capacity_reached, already_registered, rate_limited or event_not_found), or one of these, which come from the browser side:
code | Meaning |
|---|---|
missing_event | The element has no event attribute. |
load_failed | The widget script could not be downloaded (offline, or blocked by an extension or policy). |
network_error | A request to the API never got an answer. |
bot_check_failed | The Cloudflare Turnstile check could not run or did not pass. |
internal_error | An unexpected response. |
TypeScript
type WhoComingReady = CustomEvent<{ event: string; state: string }>;
type WhoComingRsvp = CustomEvent<{ rsvp_id: string; status: string }>;
type WhoComingError = CustomEvent<{ code: string }>;
document.addEventListener("whocoming:rsvp", (event) => {
const { detail } = event as WhoComingRsvp;
});With React, @whocoming/react exposes these as onReady, onRsvp and onError props.