Installation
Add the embed snippet to your HTML page. This is all you need to get started:Replace
https://app.cal.com with your Cal.com instance URL if you’re self-hosting.Quick Start Examples
Inline Embed
Embed the calendar directly in your page:Modal Embed (Button Click)
Open the calendar in a modal when a button is clicked:Floating Button
Add a persistent floating button to your page:API Reference
Initialization
Always initialize Cal before using it:Inline Method
Embed the calendar inline in a container:Modal Method
Open the calendar in a modal programmatically:Floating Button Method
Create a floating action button:UI Method
Update UI configuration dynamically:Configuration Options
Theconfig object supports the following properties:
Prefill Fields
UI Configuration
Iframe Attributes
Event Handling
Listen to booking events to integrate with your application:Listen to Events
Available Events
Remove Event Listeners
Using Namespaces
Namespaces allow multiple embeds on the same page without conflicts:Performance Optimization
Prerendering
Preload the booking page for faster modal opening:Preloading with Router
For routing forms, prerender with routing parameters:Advanced Examples
Dynamic Configuration
Update configuration based on user actions:Integration with Forms
Prefill booking data from a form:Auto-forward Query Parameters
Forward URL query parameters to the embed:?name=John&email=john@example.com will be forwarded to the embed.
Element Click Embed
Use data attributes for zero-JavaScript modal embeds:With Namespace
Debugging
Enable Logging
Addcal.embed.logging=1 to your page URL:
- Embed initialization
- Parent-iframe communication
- Event triggers
- Configuration changes
Debug Mode
Enable debug mode during initialization:Package Information
The embed snippet is part of the@calcom/embed-snippet package:
- Loads
@calcom/embed-coredynamically - Queues commands until the core library is ready
- Supports multiple namespaces
- Has zero dependencies
- Minimal file size (~2KB)
Best Practices
Initialize once per page
Initialize once per page
Call
Cal("init") once, preferably near the closing </body> tag. Multiple initializations are safe but unnecessary.Use CSS selectors carefully
Use CSS selectors carefully
Ensure your
elementOrSelector targets exist in the DOM before calling inline embed methods.Handle events early
Handle events early
Set up event listeners with
Cal("on", ...) before triggering actions that might fire those events.Clean up when needed
Clean up when needed
For single-page applications, remove event listeners when unmounting components to prevent memory leaks.
Next Steps
Customization Options
Learn about themes, styles, and branding
React Component
Use the React wrapper for React apps