calcom-vue
v2.1.0
Published
Vue 3 & Nuxt plugin for seamless Cal.com modal and embed integration
Maintainers
Readme
calcom-vue
A lightweight, type-safe Vue 3 and Nuxt 3 plugin for seamless Cal.com scheduling popup modals and inline embeds.
Features
- Vue 3 & Nuxt 3 Ready: Full SSR-safe client initialization out of the box with
getSSRProps(). - Multiple Integration Styles: Declarative
v-caldirective, pre-built<CalButton />for modals,<CalEmbed />(or<Cal />) for inline calendar layouts, and programmaticuseCal()composable. - Inline & Modal Embeds: Full support for both Cal.com popup modals and inline calendar containers.
- Modern Theming: Supports
cssVarsPerThemefor custom light/dark brand colors,theme, and custom layouts. - Self-Hosting Support: Configurable
originandembedJsUrlfor self-hosted Cal instances. - Lazy Loaded & Idempotent: Injects Cal.com's loader script only when needed on the client, preserving namespace isolation and avoiding settings overwrite.
- Fully Typed: Written in TypeScript with complete type definitions (
.d.ts).
Installation
# npm
npm install calcom-vue
# pnpm
pnpm add calcom-vue
# yarn
yarn add calcom-vue
# bun
bun add calcom-vueSetup
1. Nuxt 3
Create a universal plugin at plugins/cal.ts (do not use the .client.ts suffix so that the v-cal directive is registered during SSR, avoiding getSSRProps errors):
// plugins/cal.ts
import { defineNuxtPlugin } from '#app';
import { createCal } from 'calcom-vue';
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(
createCal({
origin: 'https://app.cal.com',
namespace: 'my-team',
theme: 'auto',
layout: 'month_view',
cssVarsPerTheme: {
light: { 'cal-brand': '#2563eb' },
dark: { 'cal-brand': '#3b82f6' }
}
})
);
});2. Vue 3 (Vite / SPA)
Register the plugin in your entry file (main.ts or main.js):
// main.ts
import { createApp } from 'vue';
import App from './App.vue';
import { createCal } from 'calcom-vue';
const app = createApp(App);
app.use(
createCal({
theme: 'auto',
layout: 'month_view',
forwardQueryParams: true
})
);
app.mount('#app');Usage
1. Inline Embed (<CalEmbed /> / <Cal />)
Render the interactive Cal.com scheduler directly inside your page layout:
<script setup lang="ts">
import { CalEmbed } from 'calcom-vue';
</script>
<template>
<div class="calendar-wrapper">
<!-- Using <CalEmbed /> or alias <Cal /> -->
<CalEmbed
calLink="john-doe/30min"
:config="{ layout: 'month_view', theme: 'light' }"
style="width: 100%; height: 650px; overflow: scroll;"
/>
</div>
</template><CalEmbed /> Props
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| calLink | string | Required | The Cal.com link (e.g., username/event-slug). |
| namespace | string | undefined | Optional Cal namespace for multi-calendar pages. |
| config | Record<string, any> | {} | Optional embed config (prefill inputs, layout, theme). |
2. Directive (v-cal)
Add v-cal to any native button, link, or clickable element to trigger the booking popup modal.
<script setup lang="ts">
import { ref } from 'vue';
const activeLink = ref('john-doe/30min');
</script>
<template>
<!-- Simple string (reactive) -->
<button v-cal="activeLink">
Book a Call
</button>
<!-- Object with custom configuration -->
<button
v-cal="{
link: 'john-doe/discovery',
namespace: 'sales',
config: {
theme: 'dark',
layout: 'week_view',
name: 'Jane Doe',
email: '[email protected]'
}
}"
>
Book Discovery Call
</button>
<!-- Using Cal.com data attributes fallback -->
<button v-cal data-cal-link="john-doe/quick-chat" data-cal-namespace="support">
Quick Chat
</button>
</template>3. Modal Button (<CalButton />)
A pre-built component for opening booking popups:
<script setup lang="ts">
import { CalButton } from 'calcom-vue';
</script>
<template>
<!-- Basic usage -->
<CalButton calLink="john-doe/30min">
Schedule 30-min Call
</CalButton>
<!-- Custom tag and configuration -->
<CalButton
tag="a"
calLink="john-doe/strategy"
namespace="custom-namespace"
:config="{
theme: 'light',
notes: 'Strategy Session'
}"
class="custom-btn"
>
Book Strategy Session
</CalButton>
</template>4. Programmatic Composable (useCal)
Use useCal for custom workflows, modals, inline mounting, asset preloading, and event tracking:
<script setup lang="ts">
import { onMounted } from 'vue';
import { useCal } from 'calcom-vue';
// Optionally specify default namespace: useCal('my-namespace')
const { openModal, preload, on, off, setUI, getApi } = useCal();
function openBooking() {
openModal({
calLink: 'john-doe/30min',
config: {
theme: 'dark',
layout: 'month_view',
name: 'Client Name',
email: '[email protected]'
}
});
}
function handleHover() {
preload({ calLink: 'john-doe/30min' });
}
onMounted(() => {
// Listen for Cal.com events (e.g. conversion tracking)
// Passing autoCleanup = true unsubscribes on scope disposal
on(
{
action: 'bookingSuccessful',
callback: (event) => {
console.log('Meeting confirmed:', event.detail);
}
},
true
);
});
</script>
<template>
<button @mouseenter="handleHover" @click="openBooking">
Book via Composable
</button>
</template>useCal() Methods
openModal({ calLink, namespace?, config? }): Opens the booking modal popup.inline({ elementOrSelector, calLink, namespace?, config? }): Mounts an inline calendar into an element or CSS selector.preload({ calLink, namespace? }): Preloads calendar assets for snappy responsiveness.on({ action, namespace?, callback }, autoCleanup?): Subscribes to events (bookingSuccessful,linkReady, etc.).off({ action, namespace?, callback? }): Unsubscribes from events.setUI(uiOptions, namespace?): Dynamically adjusts UI options for a namespace.getApi(namespace?): Returns a Promise resolving to the rawCalAPI queue function.
Configuration Reference
createCal(options) Options
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| origin | string | 'https://app.cal.com' | Cal origin URL (override for self-hosted instances). |
| embedJsUrl | string | '{origin}/embed/embed.js' | Direct URL to embed.js script. |
| namespace | string | undefined | Default global namespace. |
| forwardQueryParams | boolean | true | Forward current URL query parameters to the Cal iframe. |
| cssVarsPerTheme | CalCssVarsPerTheme | undefined | Brand colors per theme (e.g. { light: { 'cal-brand': '#2563eb' } }). |
| theme | 'light' \| 'dark' \| 'auto' | undefined | Default theme setting. |
| layout | 'month_view' \| 'week_view' \| 'column_view' | 'month_view' | Calendar layout style. |
| hideEventTypeDetails| boolean | false | Hide event header details in the modal. |
| useSlotsViewOnSmallScreen | boolean \| string | undefined | Responsive slots view for mobile viewports. |
Self-Hosted Cal.com Instances
For self-hosted instances, specify origin (and optionally embedJsUrl):
app.use(
createCal({
origin: 'https://cal.yourdomain.com',
embedJsUrl: 'https://cal.yourdomain.com/embed/embed.js'
})
);Playgrounds
Test integrations locally in either standard Vue 3 or Nuxt 3:
# Run Vue 3 playground (default: http://localhost:3000)
npm run playground
# or
npm run playground:vue
# Run Nuxt 3 SSR playground (default: http://localhost:3000)
npm run playground:nuxt