🔥 All-Access Pass — $199 USD (Regular $499) · Unlock all 2,836 Astro themes ➔
komal.nakrani
Get All-Access Pass ($199)
ThemesCategoriesDocsBlogTips & TricksPricingGet All-Access Pass ($199)
CMS & Integrations••By Komal Nakrani

Astro Booking Embeds: Calendly, Cal.com and Fast Iframes

Add Astro booking and scheduling embeds without slowing pages: a reusable component, click-to-load facades, Calendly and Cal.com setup and tracking.

#Astro#Astro Booking#Scheduling#Embeds#Performance

To add booking to an Astro site, embed your scheduling tool (Calendly, Cal.com, Google Calendar appointment pages, Microsoft Bookings or similar) on a static page, either as an iframe of your public booking URL or with the provider’s embed script. The fast way is a small Astro component that reserves the widget’s height and only loads the third-party code when the visitor scrolls to it or clicks “Pick a time”, so your page keeps Astro’s zero-JavaScript default until someone actually wants to book.

Below is a reusable booking component, provider notes, a click-to-load pattern, prefill and tracking, and the privacy and accessibility details people forget.

Key Takeaways

  • A booking embed needs no adapter or server; the provider handles availability, reminders and payments.
  • Plain iframes are the simplest and most portable embed; provider scripts add popups and events.
  • Load embeds on interaction or with loading="lazy", and reserve their height to avoid layout shift.
  • Always keep a normal link to the booking page as a fallback.
  • Listen for the provider’s postMessage events if you need conversion tracking.

Why booking embeds need care in Astro

Astro pages ship with no client JavaScript unless you add it. A scheduling widget can undo that in one line: the embed script, its stylesheet, fonts and an iframe that loads a full web app with its own scripts. On a services page, that’s often the heaviest thing on the screen, and it loads for every visitor whether they book or not.

The goal is simple: the page should be as fast as it was before the widget, and the widget should be ready the moment someone wants it. Two techniques get you there:

  1. Defer loading until the embed is near the viewport or the visitor clicks.
  2. Reserve space so the page doesn’t jump when the iframe arrives.

Our tip on lazy-loading iframes in Astro covers the general pattern; this article applies it to scheduling tools specifically.

Pick an embed style

Scheduling providers usually offer three ways to embed:

Style What the visitor sees JavaScript cost Use when
Link or button Opens the booking page in a new tab None Booking is one of many actions on the page
Inline iframe Calendar inside your page The provider’s page, inside the iframe A dedicated “Book” page
Provider script (inline or popup) Inline calendar or a modal over your page Script on your page plus the iframe You need popups, prefill helpers or events

A link is the fastest and the most reliable. Many sites only need a clear “Book a call” button that goes to the provider’s page. When booking is the main job of a page, an inline embed reduces the steps to one.

A reusable booking component

This component renders a lazy iframe of any public booking URL, reserves its height and keeps a fallback link:

---
// src/components/BookingEmbed.astro
interface Props {
  url: string;          // public booking page, e.g. https://cal.com/you/intro
  title: string;        // accessible name for the iframe
  height?: number;      // reserved height in px
}

const { url, title, height = 720 } = Astro.props;
---
<div class="booking" style={`--booking-h: ${height}px`}>
  <iframe
    src={url}
    title={title}
    loading="lazy"
    referrerpolicy="strict-origin-when-cross-origin"
    allow="payment"
  ></iframe>
  <p class="booking-fallback">
    Calendar not loading? <a href={url} target="_blank" rel="noopener">Open the booking page</a>.
  </p>
</div>

<style>
  .booking iframe {
    display: block;
    width: 100%;
    min-height: var(--booking-h);
    border: 0;
  }
  .booking-fallback { font-size: 0.9rem; margin-top: 0.5rem; }
</style>

Use it on any page:

---
// src/pages/book.astro
import BaseLayout from '../layouts/BaseLayout.astro';
import BookingEmbed from '../components/BookingEmbed.astro';
---
<BaseLayout title="Book a consultation">
  <h1>Book a 30-minute consultation</h1>
  <p>Free, by video call. Pick a time that suits you and you'll get a confirmation by email.</p>
  <BookingEmbed url="https://cal.com/your-name/consultation" title="Booking calendar" height={760} />
</BaseLayout>

loading="lazy" tells the browser to wait until the iframe is close to the viewport. The reserved min-height stops the content below it from moving. Drop allow="payment" if your bookings are free.

Not every provider allows its pages in an iframe. If the frame is blank and the browser console mentions X-Frame-Options or frame-ancestors, the provider blocks framing for that page or plan; use its embed script or a link instead.

Click-to-load: a facade for the heaviest widgets

For a booking section on a long page, a facade is better than lazy loading. Show a lightweight placeholder and only create the iframe when the visitor asks for it:

---
// src/components/BookingFacade.astro
interface Props { url: string; title: string; height?: number; label?: string }
const { url, title, height = 720, label = 'Pick a time' } = Astro.props;
---
<booking-facade data-url={url} data-title={title} style={`--booking-h: ${height}px`}>
  <a class="booking-btn" href={url} target="_blank" rel="noopener">{label}</a>
</booking-facade>

<script>
  class BookingFacade extends HTMLElement {
    connectedCallback() {
      const link = this.querySelector('a');
      link?.addEventListener('click', (event) => {
        event.preventDefault();
        const frame = document.createElement('iframe');
        frame.src = this.dataset.url!;
        frame.title = this.dataset.title!;
        frame.style.cssText = 'width:100%;min-height:var(--booking-h);border:0;display:block';
        this.replaceChildren(frame);
        frame.focus();
      }, { once: true });
    }
  }
  customElements.define('booking-facade', BookingFacade);
</script>

<style>
  booking-facade { display: block; min-height: var(--booking-h); }
</style>

The placeholder is a real link, so it still works with JavaScript disabled or blocked. When JavaScript runs, the click swaps in the calendar in place. Astro bundles and deduplicates the script, so several facades on one page cost a single small file. If you’re deciding between a custom element and a framework island for this, our guide on choosing an island or a script explains the trade-off.

Calendly in Astro

Calendly offers an inline widget, a popup widget and a popup text link. The inline widget is a div plus Calendly’s script:

---
// src/components/CalendlyInline.astro
interface Props { url: string; height?: number }
const { url, height = 700 } = Astro.props;
---
<div class="calendly-inline-widget" data-url={url} style={`min-width:320px;height:${height}px`}></div>
<script is:inline src="https://assets.calendly.com/assets/external/widget.js" async></script>

is:inline tells Astro to leave the third-party script tag as written instead of trying to bundle it. Calendly’s page URLs also accept query parameters such as hide_event_type_details=1 and hide_gdpr_banner=1 to simplify the embedded view; check Calendly’s embed options for the current list.

If you only need the calendar, the lazy iframe component above works with a Calendly booking URL too, and skips the extra script on your page.

Cal.com and other providers

Cal.com publishes booking pages at cal.com/<user>/<event> and offers inline, floating button and popup embeds from the event’s Embed tab. Paste its snippet into a component the same way as Calendly, marking the script is:inline, or use the lazy iframe component for a calendar with no script on your page.

The same approach covers Google Calendar appointment schedules, Microsoft Bookings, TidyCal, SavvyCal and booking systems for salons, clinics and restaurants. If the provider gives you a public URL, you can link it or frame it. If it gives you a script, put it in one component so it’s easy to swap later.

For analytics or chat scripts on the same page, consider moving them off the main thread with Partytown, as described in our Partytown guide. Booking widgets themselves are interactive iframes and should stay as they are.

Prefill and context from your page

Visitors hate typing their details twice. Most providers accept query parameters to prefill name and email, or to pass a source for reporting. Calendly, for example, accepts name and email. Build the URL in the component:

---
// src/pages/book/[service].astro (excerpt)
const base = 'https://calendly.com/your-name/consultation';
const params = new URLSearchParams({ utm_source: 'website', utm_content: Astro.params.service ?? '' });
const bookingUrl = `${base}?${params}`;
---

Only prefill data the visitor gave you on the same site, such as from a previous form step, and never put personal data into URLs you also log in analytics.

Track bookings without a backend

Provider scripts post messages to the parent page when something happens. Calendly sends events whose names start with calendly., including calendly.event_scheduled. Listen for them and send your own analytics event:

<!-- src/components/CalendlyTracking.astro -->
<script>
  window.addEventListener('message', (event) => {
    if (event.origin !== 'https://calendly.com') return;
    if (event.data?.event === 'calendly.event_scheduled') {
      // send to your analytics tool, e.g. window.plausible?.('Booked')
      console.log('Booking confirmed');
    }
  });
</script>

Always check event.origin; any page can post messages to yours. Cal.com and other providers have their own event names, so read their embed docs. For a server-side record, most providers can also call a webhook when a booking is made.

  • Consent. Scheduling embeds set their own cookies. If your site runs a consent banner, a click-to-load facade doubles as consent: nothing loads until the visitor asks. Mention the provider in your privacy policy.
  • Accessible names. Give every iframe a title that describes it, such as “Booking calendar”.
  • Focus. After the facade swaps in the iframe, move focus to it, as the component above does, so keyboard users don’t lose their place.
  • Fallback. Keep the plain link visible or in a <noscript> block. Ad blockers sometimes block embed scripts.

Which pages need booking

Most service businesses need the same small set: a services page with prices and durations, a booking page with the calendar, and a contact page for questions that don’t fit a slot. Salons, clinics, coaches, consultants and tutors all follow this shape. If you’re starting a services site from scratch, our Astro themes for hair and beauty and wellness businesses give you the services pages; a few, such as Stillwater, also ship a booking page, and you point its button or embed at your provider. The pages and routing docs show where a new book.astro page goes in a theme.

FAQ

How do I add Calendly to an Astro site?

Add Calendly’s inline widget div with your data-url, plus its widget.js script marked is:inline, inside an Astro component. Or embed your Calendly booking URL in a lazy-loaded iframe, which works without adding Calendly’s script to your page.

Do booking embeds need server-side rendering in Astro?

No. The scheduling provider handles availability, confirmations and reminders, so a static Astro page with an iframe or embed script is enough. You only need an adapter if you want to process booking webhooks on your own server.

Will a booking widget slow down my Astro site?

It can, because the widget loads a full web app. Load it on click with a facade or use loading="lazy" on the iframe, and reserve its height with CSS so it doesn’t cause layout shift.

Why is my booking iframe blank?

The provider is probably blocking framing with X-Frame-Options or a frame-ancestors policy, or your own Content Security Policy is missing the provider in frame-src. Check the browser console, then use the provider’s script embed or a link.

Can I track bookings from an embedded calendar?

Yes, if the provider posts events to the parent page. Calendly sends calendly.event_scheduled; listen for message events, check event.origin, and send your own analytics event. Webhooks are the more reliable option for a permanent record.