|
| 1 | +--- |
| 2 | +title: Calendly |
| 3 | +description: Embed Calendly bookings in your Nuxt app with inline, popup, and badge widgets. |
| 4 | +links: |
| 5 | + - label: useScriptCalendly |
| 6 | + icon: i-simple-icons-github |
| 7 | + to: https://github.com/nuxt/scripts/blob/main/packages/script/src/runtime/registry/calendly.ts |
| 8 | + size: xs |
| 9 | + - label: "<ScriptCalendlyInlineWidget>" |
| 10 | + icon: i-simple-icons-github |
| 11 | + to: https://github.com/nuxt/scripts/blob/main/packages/script/src/runtime/components/ScriptCalendlyInlineWidget.vue |
| 12 | + size: xs |
| 13 | +--- |
| 14 | + |
| 15 | +[Calendly](https://calendly.com) is a scheduling tool that lets visitors book time on your calendar without back-and-forth emails. The Calendly embed widget renders the booking flow inline, in a popup, or behind a floating badge button. |
| 16 | + |
| 17 | +Nuxt Scripts provides a registry script composable [`useScriptCalendly()`{lang="ts"}](/scripts/calendly) and a headless [`<ScriptCalendlyInlineWidget>`{lang="html"}](/scripts/calendly){lang="html"} component to integrate it in your Nuxt app. |
| 18 | + |
| 19 | +::script-stats |
| 20 | +:: |
| 21 | + |
| 22 | +::script-docs |
| 23 | +:: |
| 24 | + |
| 25 | +The composable comes with the following defaults: |
| 26 | +- **Trigger: Client** Script will load when Nuxt is hydrating. |
| 27 | +- **Stylesheet: Inline** The widget stylesheet (and its close-icon SVG) is inlined on first use, so no IP leak to `assets.calendly.com` on render. |
| 28 | + |
| 29 | +You can access the `Calendly` global as a proxy directly or await `onLoaded` to use it. Recommended to use the proxy for void calls; `onLoaded` is convenient when you need a stable DOM reference. |
| 30 | + |
| 31 | +::code-group |
| 32 | + |
| 33 | +```ts [Proxy] |
| 34 | +const { proxy } = useScriptCalendly() |
| 35 | +function openBooking() { |
| 36 | + proxy.Calendly.initPopupWidget({ |
| 37 | + url: 'https://calendly.com/your-name/30min', |
| 38 | + }) |
| 39 | +} |
| 40 | +``` |
| 41 | + |
| 42 | +```ts [onLoaded] |
| 43 | +const { onLoaded } = useScriptCalendly() |
| 44 | +onLoaded(({ Calendly }) => { |
| 45 | + Calendly.initInlineWidget({ |
| 46 | + url: 'https://calendly.com/your-name/30min', |
| 47 | + parentElement: document.getElementById('calendly-inline')!, |
| 48 | + }) |
| 49 | +}) |
| 50 | +``` |
| 51 | + |
| 52 | +:: |
| 53 | + |
| 54 | +## [`<ScriptCalendlyInlineWidget>`{lang="html"}](/scripts/calendly){lang="html"} |
| 55 | + |
| 56 | +The [`<ScriptCalendlyInlineWidget>`{lang="html"}](/scripts/calendly){lang="html"} component wraps [`useScriptCalendly()`{lang="ts"}](/scripts/calendly){lang="ts"} for the most common embed shape: an inline booking flow mounted into a host element you control. |
| 57 | + |
| 58 | +It's optimized for performance by using [Element Event Triggers](/docs/guides/script-triggers#element-event-triggers), only loading the Calendly widget script once the host element comes into view. By default the trigger is `'visible'`. |
| 59 | + |
| 60 | +```vue |
| 61 | +<script setup lang="ts"> |
| 62 | +const ready = ref(false) |
| 63 | +</script> |
| 64 | +
|
| 65 | +<template> |
| 66 | + <ScriptCalendlyInlineWidget |
| 67 | + url="https://calendly.com/your-name/30min" |
| 68 | + @ready="ready = true" |
| 69 | + /> |
| 70 | +</template> |
| 71 | +``` |
| 72 | + |
| 73 | +### Above-the-fold loading |
| 74 | + |
| 75 | +If the widget is above the fold and you want it to start loading on hydration rather than on visibility, set `above-the-fold` (adds a preconnect to `calendly.com`) and override the trigger. |
| 76 | + |
| 77 | +```vue |
| 78 | +<ScriptCalendlyInlineWidget |
| 79 | + url="https://calendly.com/your-name/30min" |
| 80 | + above-the-fold |
| 81 | + trigger="onNuxtReady" |
| 82 | +/> |
| 83 | +``` |
| 84 | + |
| 85 | +### Prefill, UTM, and page settings |
| 86 | + |
| 87 | +```vue |
| 88 | +<ScriptCalendlyInlineWidget |
| 89 | + url="https://calendly.com/your-name/30min" |
| 90 | + :prefill="{ name: 'Ada Lovelace', email: 'ada@example.com' }" |
| 91 | + :utm="{ utmSource: 'website', utmMedium: 'cta', utmCampaign: 'launch' }" |
| 92 | + :page-settings="{ hideEventTypeDetails: true, hideGdprBanner: true }" |
| 93 | +/> |
| 94 | +``` |
| 95 | + |
| 96 | +### Slots |
| 97 | + |
| 98 | +The component exposes `loading`, `awaitingLoad`, and `error` slots for placeholder UX while the script trigger waits or the script load fails. The default `loading` slot renders an accessible spinner. |
| 99 | + |
| 100 | +## Popup and badge widgets |
| 101 | + |
| 102 | +Popup and badge modes have no host element, so they're driven from the composable directly: |
| 103 | + |
| 104 | +::code-group |
| 105 | + |
| 106 | +```ts [Popup] |
| 107 | +const { proxy } = useScriptCalendly() |
| 108 | +function open() { |
| 109 | + proxy.Calendly.initPopupWidget({ |
| 110 | + url: 'https://calendly.com/your-name/30min', |
| 111 | + }) |
| 112 | +} |
| 113 | +``` |
| 114 | + |
| 115 | +```ts [Badge] |
| 116 | +const { onLoaded } = useScriptCalendly() |
| 117 | +onLoaded(({ Calendly }) => { |
| 118 | + Calendly.initBadgeWidget({ |
| 119 | + url: 'https://calendly.com/your-name/30min', |
| 120 | + text: 'Schedule time with me', |
| 121 | + color: '#0069ff', |
| 122 | + textColor: '#ffffff', |
| 123 | + }) |
| 124 | +}) |
| 125 | +``` |
| 126 | + |
| 127 | +:: |
| 128 | + |
| 129 | +## Prefilling invitee details and UTM parameters |
| 130 | + |
| 131 | +All four widget initialisers (`initInlineWidget`, `initPopupWidget`, `initBadgeWidget`, `initPopupWidgetWithText`) accept `prefill` and `utm` options to pre-populate the booking form and tag the booking with marketing attribution. |
| 132 | + |
| 133 | +```vue |
| 134 | +<script setup lang="ts"> |
| 135 | +const { proxy } = useScriptCalendly() |
| 136 | +
|
| 137 | +function bookFromCampaign(user: { name: string, email: string }) { |
| 138 | + proxy.Calendly.initPopupWidget({ |
| 139 | + url: 'https://calendly.com/your-name/30min', |
| 140 | + prefill: { |
| 141 | + name: user.name, |
| 142 | + email: user.email, |
| 143 | + }, |
| 144 | + utm: { |
| 145 | + utmSource: 'website', |
| 146 | + utmMedium: 'cta', |
| 147 | + utmCampaign: 'launch', |
| 148 | + }, |
| 149 | + }) |
| 150 | +} |
| 151 | +</script> |
| 152 | +``` |
| 153 | + |
| 154 | +::script-types |
| 155 | +:: |
| 156 | + |
| 157 | +## Example |
| 158 | + |
| 159 | +Loading Calendly through `app.vue` when Nuxt is ready, with the inline widget rendered on a booking page. |
| 160 | + |
| 161 | +```vue [app.vue] |
| 162 | +<script setup lang="ts"> |
| 163 | +useScriptCalendly({ |
| 164 | + scriptOptions: { |
| 165 | + trigger: 'onNuxtReady', |
| 166 | + }, |
| 167 | +}) |
| 168 | +</script> |
| 169 | +``` |
0 commit comments