Vue quickstart (Vite)
A Vue website, built with Vite, where customers pick a service and a free time and book an appointment, all in the browser with the Booking SDK.
Tutorial5 min read
In about 15 minutes you build a small Vue website where customers of Northwilds Oslo choose a service, pick a free time in their own time zone and book it. Everything runs in the visitor's browser, so each visitor has their own rate limits.
Tested with: Vite 8.3, Vue 3.5, TypeScript 6.0, @bifrost-orbit-booking/sdk 0.1.0, Node.js 24, against a local Booking Orbit.
Note
The SDK is not on npm yet. Until it is, step 2 fails; the code shows the calls to make with the public booking API.
Before you start
You need:
- A Booking Orbit location with at least one service and someone who takes it, such as
northwilds-oslo. Its short name is the last part of its booking page address. - Your website allowed: under the location's Settings › Your website, add
http://localhost:5173to Other websites while you build, and your real website's address before you go live. See Allowed websites. - Node.js 20 or later.
1Create the project
npm create vite@latest northwilds-booking -- --template vue-ts --no-interactivecd northwilds-bookingrm -r src/components src/assets2Install the SDK
npm install @bifrost-orbit-booking/sdk3Add the settings
VITE_BOOKING_URL=https://app.bifrostorbit.com/bookingVITE_BOOKING_LOCATION=northwilds-osloNeither is a secret: the booking API needs no key. Tell TypeScript about them:
/// <reference types="vite/client" />interface ImportMetaEnv { readonly VITE_BOOKING_URL: string; readonly VITE_BOOKING_LOCATION: string;}4Create the client
One client books one location. The helpers show times in the visitor's own time zone.
import { createBookingClient } from "@bifrost-orbit-booking/sdk";export const booking = createBookingClient({ baseUrl: import.meta.env.VITE_BOOKING_URL, location: import.meta.env.VITE_BOOKING_LOCATION, locale: "en",});export const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;export const timeOf = (iso: string) => new Intl.DateTimeFormat("en-GB", { timeZone, hour: "2-digit", minute: "2-digit" }).format(new Date(iso));export const dayOf = (date: string) => new Intl.DateTimeFormat("en-GB", { timeZone: "UTC", weekday: "long", day: "numeric", month: "long" }).format(new Date(`${date}T12:00:00Z`));export const dateOf = (iso: string) => new Intl.DateTimeFormat("en-GB", { timeZone, weekday: "long", day: "numeric", month: "long" }).format(new Date(iso));dayOf takes a day such as 2026-11-12 from the free times, which are already grouped in the visitor's time zone. dateOf and timeOf take a time.
5Build the booking screen
Replace src/App.vue:
<script setup lang="ts">import { onMounted, ref } from "vue";import { BookingError, isTimeTaken, type BookingAppointment, type BookingHold, type BookingService, type BookingSlots } from "@bifrost-orbit-booking/sdk";import { booking, dateOf, dayOf, timeOf, timeZone } from "./booking";const services = ref<BookingService[]>([]);const service = ref<BookingService | null>(null);const slots = ref<BookingSlots | null>(null);const hold = ref<BookingHold | null>(null);const startsAt = ref<string | null>(null);const booked = ref<BookingAppointment | null>(null);const error = ref<string | null>(null);const name = ref("");const email = ref("");onMounted(async () => { try { services.value = await booking.services(); } catch (failure) { error.value = (failure as Error).message; }});async function choose(next: BookingService) { service.value = next; slots.value = null; slots.value = await booking.slots({ service: next.id, timeZone, days: 7 });}async function pick(time: string) { error.value = null; try { hold.value = await booking.hold({ service: service.value!.id, startsAt: time }); startsAt.value = time; } catch (failure) { error.value = (failure as Error).message; if (isTimeTaken(failure)) await choose(service.value!); }}async function book() { try { const { appointment } = await booking.book({ service: service.value!.id, startsAt: startsAt.value!, holdToken: hold.value!.token, name: name.value, email: email.value, timeZone }); booked.value = appointment; } catch (failure) { error.value = failure instanceof BookingError ? failure.message : "Something went wrong. Try again."; if (isTimeTaken(failure)) { hold.value = null; await choose(service.value!); } }}</script><template> <main v-if="booked"> <h1>You're booked</h1> <p>{{ booked.service.name }} with {{ booked.staff ?? "our team" }}, {{ dateOf(booked.startsAt) }} at {{ timeOf(booked.startsAt) }}.</p> <p>Your reference is {{ booked.reference }}. We've sent the details to {{ booked.attendee?.email }}.</p> <p><a :href="booked.manageUrl">Change or cancel</a></p> </main> <main v-else> <h1>Book at Northwilds Oslo</h1> <p v-if="error" role="alert">{{ error }}</p> <ul> <li v-for="entry in services" :key="entry.id"> <button type="button" :aria-pressed="service?.id === entry.id" @click="choose(entry)">{{ entry.name }}, {{ entry.durationMinutes }} minutes</button> </li> </ul> <section v-if="slots && !hold"> <h2>Pick a time</h2> <template v-for="day in slots.days" :key="day.date"> <div v-if="day.slots.length"> <h3>{{ dayOf(day.date) }}</h3> <button v-for="slot in day.slots" :key="slot.startsAt" type="button" @click="pick(slot.startsAt)">{{ timeOf(slot.startsAt) }}</button> </div> </template> <p v-if="slots.days.every((day) => !day.slots.length)">No free times this week{{ slots.next ? `. The next is ${dateOf(slots.next.startsAt)}.` : "." }}</p> </section> <form v-if="hold && startsAt" @submit.prevent="book"> <h2>{{ service!.name }} at {{ timeOf(startsAt) }}</h2> <p>We're holding this time for you for 10 minutes.</p> <label>Name <input v-model="name" name="name" required autocomplete="name" /></label> <label>Email <input v-model="email" name="email" type="email" required autocomplete="email" /></label> <button type="submit">Book</button> </form> </main></template>What happens:
services()lists the services on the booking page.slots()asks for seven days of free times in the visitor's time zone.hold()keeps the chosen time for 10 minutes while the visitor types. If someone else took it a moment ago, the free times load again.book()books with the hold's token. Booking Orbit emails the confirmation and the reminders, andmanageUrlis the visitor's page to change or cancel.
6Run it
npm run devOpen http://localhost:5173, choose a service, pick a time and book. The booking appears under Calendar in Booking Orbit. Cancel it with the Change or cancel link when you're done.
If the free times load but booking fails with "This website isn't allowed to book here", the address in your browser isn't among the allowed websites yet.
Make it yours
- Ask what the location asks:
location()says whether a phone number and notes arerequired,optionalorhidden.service(id)returns the form's questions; send the answers asanswers, keyed by question id. See Booking in the public booking API. - Let customers choose a person:
staff(service)lists the people, andslots({ service, staff })their own times. - Paid services: The SDK doesn't take payments. For a service paid online when it's booked,
hold()andbook()throwBookingPaymentRequiredError. Check withisPaymentRequired(error)and send the customer toerror.bookingUrl, the booking page with the time already chosen, or open the widget. - Paused locations: Catch
BookingPausedErrorand say that online booking is unavailable for now.
Was this page helpful?