# Embed the booking widget

> Show Booking Orbit's booking screens inside a page of your website or in a popup, with one script tag, and open it from your own code.

Source: https://docs.bifrostorbit.com/booking/developers/embed-the-widget/

The widget shows the location's booking screens on your own website: services, free times, the form and, where a service is paid in advance, the payment with Stripe. It needs no key and works on any website, because the booking itself happens inside the widget, on Booking Orbit's own address.

**Booking page** in Booking Orbit has the code ready to copy, for every service or for one.

## 1. Add the script

Add it once per page, anywhere in the page:

```html
<script src="https://app.bifrostorbit.com/booking/widget.js" async></script>
```

## 2. Show it in the page

Put a placeholder where the booking screens should appear:

```html
<div data-booking-orbit="northwilds-oslo"></div>
```

The widget grows with its content, so there is no scroll bar inside it, and is at least 480 pixels high while it loads.

## 3. Or open it in a popup

Any button or link with `data-booking-orbit-open` opens the widget in a popup:

```html
<button type="button" data-booking-orbit-open="northwilds-oslo" data-service="boot-fitting">Book a boot fitting</button>
```

The popup closes with its close button or a click beside it, and gives the focus back to the button.

## Options

Both placeholders take the same attributes:

| Attribute | |
| --- | --- |
| `data-booking-orbit` or `data-booking-orbit-open` | The location's short name, such as `northwilds-oslo` |
| `data-service` | Start with one service, by its short name or id, such as `boot-fitting` |
| `data-staff` | Start with one person, by their id from `GET /staff` |
| `data-lang` | The language, such as `en`, `nb` or `de`, from the languages the location offers |
| `data-theme` | `light` or `dark`, to match your website. If left out, the booking page follows the visitor's device. |
| `data-title` | The frame's title for screen readers. "Book an appointment" if left out. |

The widget uses the location's colour from **Settings**.

## From your own code

The script adds `window.BookingOrbit`:

```js
BookingOrbit.open({ location: "northwilds-oslo", service: "ski-service", lang: "nb" });
BookingOrbit.close();
BookingOrbit.mount(document.querySelector("#booking"), { location: "northwilds-oslo" });
BookingOrbit.scan();
```

- `open(options)` opens the popup, and `close()` closes it.
- `mount(element, options)` adds the widget inside an element.
- `scan()` looks for new `data-booking-orbit` placeholders, for pages that add them after loading, such as single-page apps. It skips placeholders it has already filled.

The options are `location`, `service`, `staff`, `lang` and `title`, as the attributes above.

In React or Vue, add the script once and call `BookingOrbit.scan()` after the placeholder is on the page, or call `BookingOrbit.open()` from a click handler.

## What it does and doesn't do

- Bookings through the widget count as **Widget** under **Reports**, where bookings come from.
- Customers get the same emails, reminders and manage page as from the booking page.
- The widget doesn't tell your page when someone has booked yet. To act on bookings, use [events](https://docs.bifrostorbit.com/booking/developers/events/), or build your own screens with the [Booking SDK](https://docs.bifrostorbit.com/booking/developers/booking-sdk/).
- Your page's styles don't reach inside the widget, and the widget's don't reach your page.

## Content Security Policy

If your website sends a Content Security Policy, allow the script and the frame:

```text
script-src https://app.bifrostorbit.com;
frame-src https://app.bifrostorbit.com;
```
