Widget reference
Two dependency-free custom elements turn any HTML page into a booking page:
<nise-booking>— the booking flow (service → time → details → payment → done).<nise-events>— the event/ticket shop.
Both render into an open shadow DOM, read their configuration from data-* attributes, and talk to
the public API directly from the browser. There is no iframe, no build step and no
npm package.
Contents
- Embedding
- Language
- The API base URL
<nise-booking>attributes- Booking flow step by step
- Package mode
- Recurrence, cart and chain in the widget
- Waitlist and occupancy
- Payment step and return handling
<nise-events>- Events for your page
- Styling
- Accessibility
- WordPress
- Limits, caching and versioning
- What the widget cannot do
Embedding
<script src="https://app.nisebookings.com/widget.js" defer></script>
<nise-booking data-key="YOUR_PUBLIC_KEY"></nise-booking>
<script src="https://app.nisebookings.com/events.js" defer></script>
<nise-events data-key="YOUR_PUBLIC_KEY"></nise-events>
- The scripts are classic scripts (not modules), need no dependencies, and register the element only if it is not registered yet — loading the script twice is harmless.
- Keep
defer: the elements upgrade themselves and start loading as soon as they are connected. - One element instance per page slot. The element has no constructor options and no methods; it fires
events your page can listen to. The only global it sets is
window.nisebookings.version. - The widget needs no cookies and sends no credentials.
Language
The customer-facing texts ship in Dutch, English and German. Each element resolves its language on its own, in this order:
data-langon the element — trimmed and lowercased; anything starting withnlis Dutch, withdeGerman, everything else English. Use it to run one page, or one embed, in another language than the account.- The account's language — Instellingen → Algemeen → Taal van het boekingsformulier
(Nederlands/Engels;
localeinPATCH /api/v1/settings). It arrives withGET services. - Dutch, when neither is set.
<nise-booking data-key="…" data-lang="en"> sets lang on its host element (the shadow tree
inherits it) and re-renders the current step when data-lang changes; <nise-events data-lang="en">
reads the attribute on connect and again after the first fetch. On WordPress the plugin shortcodes
take the same value: [nise_booking lang="en"] and [nise_events lang="en"] ("nl" for Dutch,
"de" for German); [nise_booking picker="list"] passes data-picker;
without it they follow the account language.
Dates and times follow the widget's language, so an English widget on a Dutch account says
"Monday 30 November". Not translated on purpose: server data (service, staff and event titles and
descriptions) and amounts, which follow the account's locale (€ 1.234,56). A booking made in
Dutch, English or German gets its customer e-mails and customer pages in that language. The account
language can be German too; the admin itself stays Dutch or English, and the legal documents are English.
The API base URL
The widget decides once, at script-load time, where the API lives:
data-api="https://app.nisebookings.com"if present — used verbatim (no trailing-slash normalisation);- otherwise the origin of the script's own
src(https://app.nisebookings.com/widget.js→https://app.nisebookings.com); - otherwise the embedding page's origin.
If you load the scripts from anywhere other than https://app.nisebookings.com, data-api is
mandatory. Note that document.currentScript is
null for module scripts, inline scripts and dynamically injected async scripts; in those cases the
fallback is the page origin, so set data-api explicitly.
Requests without an Origin header work too (server-to-server), but for browser embeddings your
account's Toegestane websites list applies (Instellingen → Insluiten). Empty list = any site;
otherwise the API answers 403 origin_not_allowed.
<nise-booking> attributes
| Attribute | Default | Meaning |
|---|---|---|
data-key |
— | Required. Your account's public key. |
data-api |
script origin | API base URL (see above). |
data-service |
— | Preselect a service id (from GET services); the category and service selects open on it. The widget skips the service step only when the service has fewer than 2 staff (or hides staff), no extras, capacity 1, the chain feature is off and the entry is not already in the cart. |
data-staff |
any |
Preselect a staff id, or any. Ignored when the chosen service is not offered by that staff member (falls back to any). |
data-package |
— | Package mode for an already bought package: the token from the /p/<token> link. |
data-lang |
account language | Language of the customer-facing texts: nl, en or de (anything not starting with nl or de means English). See Language. |
data-picker |
select |
How step 0 offers the services: two selects (category, then service), or list for the vertical list of buttons with description, duration and price. See Step 0. |
data-theme |
light | dark for the dark palette, auto to follow the visitor's system. See Styling. |
Attributes are read on connect only — except data-theme (pure CSS, so a change applies at once) and
data-lang, which the element observes: changing it
after the element is in the DOM switches the language (and the host's lang attribute) and
re-renders. No other attribute has an attributeChangedCallback, and re-inserting the same element
does not re-initialise it. If you need a different configuration, create a new element (or replace
the old one).
Booking flow step by step
Steps are 0 services, 1 time, 2 details/payment, 3 done, 4 payment-status message,
5 cart. Above each heading a small step indicator (an <ol> labelled "Stappen", the current step
aria-current="step") reads Dienst · Tijd · Gegevens · Klaar — Datum instead of Tijd for a
day service, without Dienst in package mode; the overview counts as Tijd, and the payment-status
message and the plan-limit notice show no indicator.
Step 0 — Kies een dienst. By default two selects: Categorie (the categories by their
Volgorde; services without a category are grouped as Overig, last) and Dienst (by the
services' Volgorde, then name),
filled with that category's services as "title · duration · price" (packages: "N dagen geldig"/
"onbeperkt geldig"). With fewer than two categories only Dienst shows. Until a category is chosen
the service select is disabled; picking another category clears a service from a different one. The
chosen service's description and its options panel appear under the selects; focus stays on the
service select, so browsing it with the arrow keys does not jump away. Nothing advances on its own:
the customer presses Kies een tijd. With data-picker="list" the step shows the service list
instead (title, description, duration and price per row); the chosen service's options open in a
panel right under it, so on a phone they appear where the customer tapped, and focus moves to the
first of them; a service without options (one staff member, no extras, capacity 1, chain off) goes
straight to the time step. A staff <select> ("Medewerker", first option "Maakt niet uit")
appears only when the service has more than one public staff member and the business has not hidden
staff for collaborative services. "Aantal personen" appears when capacity > 1. Extras render as
checkboxes (single-choice) or number inputs; mandatory extras are pre-set and disabled. Buttons:
Kies een tijd (packages: Verder), Dienst toevoegen (chain), Deze dienst weglaten /
Geen dienst toevoegen, Terug naar je afspraken (cart). Empty: "Er zijn nu geen diensten te
boeken."
Step 1 — Kies een tijd. One week at a time with Vorige week / Volgende week
(hasMore from the API decides whether "next" is enabled). The week is a strip of seven day buttons
(short weekday + date; a day without free times is disabled); the first day with times is chosen, and
only the chosen day's times show, split into Ochtend (before 12:00), Middag (12:00–17:00) and
Avond (from 17:00). A day service (rental) lists its start dates as one row instead. Occupancy is shown only when Bezetting tonen is on and capacity > 1: 3/8
("Bezette plaatsen") or nog 5 ("Vrije plaatsen"). Waiting-list slots are greyed with
"wachtlijst (N)". While loading, grey placeholder rows hold the space (the loading text "Tijden laden…" is announced to
screen readers only; the first load of the widget does the same). Empty "Geen vrije tijden in deze week. Kijk een week
verder.", failure "De tijden kunnen nu niet worden geladen. Probeer het opnieuw." with an Opnieuw proberen button.
Step 5 — Je afspraken (overview; shown once the order holds more than one appointment, or when the customer opens Herhalen). Lists each entry with service, extras, day/time, staff, "· herhaald" for series, and per entry Wijzigen, Verwijderen and, when the service allows repeats, Herhalen / Herhaling aanpassen. Footer: Verder and Nog een afspraak. A single appointment skips this step: after choosing a time the customer lands on step 2, where the summary carries Wijzigen, Herhalen (when the service allows repeats) and Nog een afspraak (when winkelmand is on); with more than one appointment it carries Afspraken aanpassen. What was typed on step 2 is kept when the customer leaves it through one of these buttons and comes back.
Step 2 — Je gegevens. Fields Naam, E-mail, Telefoon, Opmerking, then the service's own intake
questions (Instellingen → Diensten → Velden: text, textarea, choice, checkbox, number, date or file —
JPG/PNG/WebP/PDF up to 5 MB, uploaded before the booking is sent, picked with a Kies een bestand
button in the widget's language; optional fields are marked "(optioneel)" — Telefoon, Opmerking and
every non-required question except a checkbox — so unmarked means required; a per-person one renders a
control per person as "Persoon 1", "Persoon 2" (a single person just sees the question), and a conditional one
(Toon alleen als) appears and disappears as the customer answers the question it depends on —
see the public API's
fields and {fields} in mails); then, when something has to be
paid: the coupon field (Toepassen), payment method radios (Ter plaatse betalen / Online
betalen (iDEAL, creditcard en meer) — only when the business offers both), and, for Mollie orders where
any service has a deposit other than 100%, the choice Alleen de aanbetaling / Het hele bedrag.
A live price summary (refreshed through POST quote, 250 ms debounce) shows Totaal, plus Subtotaal
and Korting only when a coupon applies, a VAT line ("waarvan btw" when prices include VAT, "Btw"
otherwise) only when VAT is non-zero, "Nu te betalen" / "Later te betalen" for deposits and "Ter
plaatse te betalen (herhaalde afspraken)" when part of a series is paid on site.
Submit: Afspraak bevestigen, or Naar betalen for an online payment. Notes appear for waiting
list ("Je komt op de wachtlijst, je betaalt nu niets.") and package bookings ("Gebruik het
e-mailadres waarmee je het pakket hebt gekocht.").
Step 3 — done. Heading and text follow the result: "Je afspraak staat vast" when every timed item
is approved, "Je aanvraag is ontvangen" when something is still pending, "Je staat op de wachtlijst"
for waiting-list-only orders, "Je pakket is besteld" for package purchases.
Nog een afspraak maken restarts (in package mode it reloads the package).
Error handling is inline and specific:
| Situation | Message |
|---|---|
| Slot taken between choosing and submitting (409) | "Een gekozen tijdstip is net geboekt. Kies een ander tijdstip." — the entry is highlighted, or reopened for editing when it was the only one. |
| Validation (422) | Per-field messages ("Vul je naam in.", "Vul een geldig e-mailadres in.", "Vul een geldig telefoonnummer in.", "Je opmerking is te lang.") + "Controleer de gemarkeerde velden."; focus moves to the first invalid field. |
Persons outside the range (422 on slots) |
"Kies 6 t/m 20 personen." — from the min/max the server sends. The persons field already starts at the service's capacityMin and cannot go below it, so this only shows when a chosen staff member has a higher minimum. |
| Invalid coupon | "Deze code is ongeldig of al gebruikt." / "Deze code is verlopen." — the field is cleared and the price re-quoted. |
| Package errors | "Dit pakket hoort bij een ander e-mailadres.", "Dit pakket is verlopen.", "Dit pakket is opgebruikt." |
| Waiting list full | "De wachtlijst voor dit tijdstip is vol. Kies een ander tijdstip." |
| Mollie unavailable (502) | "Online betalen lukt nu even niet. Kies ter plaatse betalen of probeer het later opnieuw." |
| Anything else | "Er ging iets mis bij het boeken. Probeer het opnieuw." |
| Services unreachable | "De agenda kan nu niet worden geladen." with an Opnieuw proberen button |
| Times unreachable | "De tijden kunnen nu niet worden geladen. Probeer het opnieuw." with Opnieuw proberen (it no longer reads as "no free times") |
| A request hangs | after 20 s (2 min for an upload) it counts as failed and the matching message above appears |
Package mode
<nise-booking data-key="…" data-package="<token>"> (this is what /p/<token> renders) loads
GET packages/<token> and locks the widget to that package:
- The service list is replaced by the package's service with the package's fixed staff (or free choice), price 0, and the widget jumps straight to the time step.
- A banner shows "
<packageTitle>· nogNvanM· geldig t/mdate". - Cart and chain are disabled inside package mode; the API refuses paid booking of package visits.
- Invalid or used-up packages render "Dit pakket is opgebruikt of verlopen." / "Dit pakket is niet gevonden."
Recurrence, cart and chain in the widget
- Herhalen (visible per entry when the service offers frequencies): choose Hoe vaak (Elke dag /
Elke week / Om de week / Elke maand), the interval for daily ("Om de hoeveel dagen"), weekdays for
weekly ("Op", ma–zo), a monthly option (a day number, "de Ne
", or "de laatste "), and either Aantal keer (2–52) or Of tot en met (a date). Data zoeken calls POST recurrenceand lists every occurrence; moved ones show "· ander tijdstip", ones without a time show "· geen tijd gevonden", each removable. The whole series is sent as one order with a series key. - Cart: with winkelmand on, Nog een afspraak (on the details step, then on the overview) adds
another selection; all are sent as one order; earlier entries are
passed as
holdduring slot searches so the customer never sees their own choices as free. - Chain: "Dienst toevoegen" adds a second service that must run right after the first; the time
step then searches chain slots (
POST slotswith multiple items) and shows each part's time.
Waitlist and occupancy
Waiting-list slots appear only when the business enabled the waiting list and the service allows it. A
slot row shows "wachtlijst (N)" where N is the number of people already waiting. Booking one creates a
waitlisted booking without payment; when a seat frees up the customer receives the waitlist_offer
mail with a first-come-first-served /w/<token> link.
Payment step and return handling
For an online (Mollie) payment the widget redirects to the returned checkoutUrl. On return, with
nb_pay=<token> in the URL, it removes that parameter (history.replaceState), shows "Betaling
controleren…" and polls GET payments/<token> every 2 seconds, up to 15 times:
- completed → the done step ("Je betaling is ontvangen.").
- failed/refused → "Betaling niet gelukt" / "De betaling is niet gelukt. Je afspraak is niet geboekt." with Opnieuw proberen (restarts the flow at the service step and clears the cart).
- still pending after 30 s → "Betaling wordt verwerkt" / "Je betaling wordt nog verwerkt. Je krijgt een bevestiging per e-mail."
You do not need a thank-you page of your own when you use the widget: pass a returnUrl on your page
and the widget handles the return. When you build a custom checkout, do the same polling yourself —
see 04-public-api.md.
<nise-events>
Attributes: data-key, data-api, data-theme (Styling) and data-lang (read on connect and again after the first fetch;
see Language).
- List: each published event shows title, date range (localised, business time zone), optional image,
info, and a row per ticket type with price ("gratis" when 0) and "nog N" or "uitverkocht"; quantity
inputs are capped at
min(left, 50). Tickets kiezen continues; without a selection: "Kies ten minste één ticket." - Form: Naam, E-mail, Telefoon, and when the total is > 0 and both gateways are enabled, the same
Betaalwijze radios. Tickets bestellen sends
POST events/<id>/tickets. - Done: "Je tickets zijn besteld" with the codes, or "Je codes krijg je na betaling." when the order is not approved yet.
- Payment return: the same 2-second polling, but it requires both
nb_payandnein the URL (ne=1is what this widget writes into its ownreturnUrl, so a booking widget on the same page does not pick up the ticket payment). - No coupon, no notes, no deposit choice, no per-item price breakdown.
- Errors: "Er zijn niet genoeg tickets meer. Kies opnieuw." (sold out), "De verkoop voor dit evenement is gesloten.", "Online betalen lukt nu even niet. Kies ter plaatse betalen of probeer het later opnieuw.", "Er ging iets mis bij het bestellen. Probeer het opnieuw."
Events for your page
<nise-booking> fires CustomEvents on the element. They bubble and cross the shadow boundary, so a
listener on document works too. detail never contains the customer's name, e-mail, phone or answers.
| Event | When | detail |
|---|---|---|
nise:ready |
the services are loaded and the first step is shown | { version, lang, services, limitReached } |
nise:step |
the visible step changes | { step } — service, time, overview, details, done or message (payment status) |
nise:booked |
an order is final: created without online payment, or the online payment came back completed | { items: [{ id, status, start, service, staff }], paid, total?, currency? } — status is approved, pending or waitlisted; total and currency only when nothing was paid online |
nise:error |
something failed that the customer sees | { code, status? } — load, slots, slot_unavailable, validation, upload_failed, payment_unavailable, payment_failed, plan_limit, booking_failed |
<script>
document.addEventListener('nise:booked', (e) => {
// e.g. a conversion in your own analytics, or your own thank-you page
window.plausible?.('Booking', { props: { service: e.detail.items[0].service } });
});
</script>
With an online payment the customer leaves for Mollie and comes back to the same page; nise:booked
fires then, once, with paid: true. Ask your own analytics whether it may run on the return page.
Styling
The shadow DOM isolates internal styles; the host exposes design tokens as CSS custom properties. Set them on the element (or any ancestor):
nise-booking, nise-events {
--nb-accent: #E5006F; /* buttons, links, highlights */
--nb-accent-hover: #C2005E;
--nb-on-accent: #fff; /* text on accent buttons (dark theme: #1C1B24, keeps 4.5:1) */
--nb-text: #1A1A1F;
--nb-text-2: #4A4B68;
--nb-text-3: #6E6F88; /* muted meta text */
--nb-bg: #fff;
--nb-sunken: #F7F8FB; /* cards, panels */
--nb-border: #E6E7EE;
--nb-border-strong: #C7C6D1;
--nb-danger: #CF2E36;
--nb-focus: #FF4D9B; /* focus ring */
--nb-radius: 4px;
--nb-weight-strong: 400; /* labels, buttons, the current step; body text inherits */
}
fontis inherited from the page, weight included (the host sets onlyline-height: 1.6), so your typography reaches the widget; labels and buttons use--nb-weight-strong. Sizes and colours come from the variables above.Dark sites:
data-theme="dark"on<nise-booking>or<nise-events>switches to the nise dark palette;data-theme="auto"follows the visitor's system setting. Your own--nb-*values still win over both, so a dark site can set just--nb-bgto its own background.The host is
display: block; max-width: 640px. Control the width with a wrapper.<nise-booking>exposes these parts for::part(); everything else (class names, structure) is implementation detail and may change:Part What headingthe step heading ( h2)stepsthe step indicator ( ol)servicea service in the list ( data-picker="list")optionsthe panel under the chosen service (or under the selects) daya day in the week strip ( [aria-pressed="true"]when chosen,:disabledwithout times)slota time (or a start date for a rental) button,primarybuttons; the main action carries both ( ::part(button primary)or::part(primary))linktext-style buttons (Terug, Wijzigen, …) inputtext inputs, selects and textareas of the form summarythe price summary ( dl)errorthe error line nise-booking::part(slot) { border-radius: 999px; } nise-booking::part(primary) { text-transform: uppercase; letter-spacing: .04em; }<nise-events>has no parts yet; style it with the variables.Customer-facing texts are the built-in Dutch/English strings (Language); only names, prices, durations and the time zone come from the API (your account's
locale,currencyandtimeZone); dates are formatted in the widget's language.
Accessibility
- The error line is
role="alert" aria-live="assertive"; the loading line and the price summary arearia-live="polite". - Headings are
h2withtabindex="-1"and receive focus on each step change (without a focus ring: the heading is not a control). - Service choices and the day strip are buttons with
aria-pressed; the selected one is exposed as a toggle state. - Each block of times is a
role="group"labelled with the day and the part of the day, so a screen reader hears "vrijdag 16 oktober · Middag" before "14:30". A disabled day's label says it has no times. - Invalid fields get
aria-invalidplusaria-describedbypointing at their message, and focus moves to the first invalid field after a failed submit. - Inputs are wrapped in or bound to
<label>s; focus styling uses:focus-visiblewith a 2 px ring. - The container is keyboard-operable end to end (links, buttons, radios, selects).
- Hover transitions are 150 ms; with
prefers-reduced-motion: reduceevery transition and the loading pulse are off.
WordPress
No plugin is needed. In the block editor, add a Custom HTML block to any page or post and paste the
two lines from Embedding (widget.js + <nise-booking>, or events.js +
<nise-events>). The data-service, data-staff and other attributes work the same way,
data-lang included. The plugin's shortcodes take the language as lang: [nise_booking lang="en"]
and [nise_events lang="en"] (or "nl"; without it, the account's language). Your
WordPress user must be allowed to add scripts (administrators are, by default). Add the
WordPress site to Toegestane websites in the booking app, or leave that list empty.
Limits, caching and versioning
| Limit | Value |
|---|---|
| Items per order | 60 (server), chain parts 10 (server); the widget itself adds no cap |
| Chain/search window | 31 days per slots call (the widget asks one week at a time) |
| Recurrence | 2–52 occurrences, interval 1–30 |
| Name / email | 255 characters |
| Phone | 50 characters |
| Notes | 2000 characters |
| Coupon code | the widget's field allows 50; the API accepts 40 |
| Ticket quantity | 1–50 per type, at most 20 types |
| Script sizes (budget) | widget.js ≤ 24 KB gzip (≈23.1 KB now; raised from 20 KB in 0.5.0 for the day strip, events, parts, dark theme and placeholders, and from 22 KB in 0.6.0 for German and the category picker), events.js ≤ 8 KB gzip (≈6.8 KB now); all three languages ship in the same file, no build step |
- Version marker. The first of the two scripts that loads logs
nisebookings@0.6.4to the browser console (once per page) and setswindow.nisebookings.version. That is how you tell which build a page is running — a page that mixes a stale cached script with a fresh one reports whichever loaded first. - Cache-busting. Appending a version query to the script URL (
/widget.js?v=0.6.4) is supported: it forces a fresh fetch, and the file served does not depend on the query. The WordPress plugin adds?ver=0.6.4automatically. After an update a browser may otherwise briefly keep an old copy; a hard refresh fixes it too. - Load both scripts from
https://app.nisebookings.comso you always get the current version. A copy served from elsewhere needsdata-apiand does not update itself.
What the widget cannot do
- Intake questions and file uploads (JPG, PNG, WebP or PDF, up to 5 MB) yes, both in step 2; customer accounts no.
- Only Dutch, English and German (Language): no fourth language, no way to override individual strings.
- No methods to call and no way to drive it from your own script: it only tells your page what happened (Events for your page). To drive the flow yourself, build on the public API instead.
- No rescheduling inside the widget; customers cancel or move their booking through the mail link
(
/b/<token>). - When the account's plan has used up its monthly booking allowance, the widget shows a single notice
("Online boeken is op dit moment niet mogelijk") instead of the service picker, and a booking that
races past the limit gets the same message — the server refuses it with
402 plan_limit. - Day-based services (rentals per whole day,
durationDays≥ 1) show a start-date picker instead of the time grid: the service line reads "N dagen · € X per dag", the customer picks a start date, and the summary and confirmation show the span ("woensdag 21 oktober → zaterdag 24 oktober · 3 dagen"). Such a service cannot be combined with other items in a chain or cart (button hidden, the API also refuses it). - No styling beyond the custom properties above, no
::part, no theme attribute.