- Overview
- Introduction to Cal.com Atoms
- Setup
- Apple calendar connect
- Availability settings
- Booker Embed
- Booker
- Bookings hooks
- Cal OAuth Provider
- Cal Provider
- Calendar settings
- Calendar view
- Calendars hooks
- Conferencing Apps
- Create schedule
- Event Type
- Event types hooks
- FAQ
- Google calendar connect
- List Event Types
- List schedules
- Onboarding Embed
- Outlook calendar connect
- Payment form
- Quickstart
- Stripe Connect
- Troubleshooter
- User / Teams hooks
- Bookings hooks
- Calendars hooks
- Event types hooks
- FAQ
- Introduction
- Quickstart
- User / Teams hooks
- Apple calendar connect
- Availability settings
- Booker Embed
- Booker
- Cal OAuth Provider
- Cal Provider
- Calendar settings
- Calendar view
- Conferencing Apps
- Create schedule
- Event Type
- Google calendar connect
- List Event Types
- List schedules
- Outlook calendar connect
- Payment form
- Stripe Connect
- Troubleshooter
- Managing booking fields
- Booking redirects
- Custom booking flow
- Custom slot selection flow
- Global event types
- Managed organizations
- Custom toasts
- Configuring your team
Booking redirects
Archived Cal.com Atoms documentation for Booking redirects. These deprecated SDK components are no longer maintained.
This is now deprecated and under maintenance for existing users only - no new customers can sign up for the platform plan
When creating an OAuth client you can specify:
- booking URL to manage where people land after booking after one of your users.
- reschedule URL to your page for rescheduling a booking.
- cancel URL to your page for cancelling a booking.
This guide will explain each of the URLs and how to create page for each of them using atoms and our hooks.
Booking URL
After a person books one of your users, that person should see the successful booking.
Page in the booking URL will take URL parameter provided by us and then hook to fetch the booking and then display it. Here is an example:
- Pass
my-app.com/bookingsas the redirectURI. - In your app, create
my-app.com/bookings/[bookingUid]page where bookingUid will become path parameter. - When a booking occurs, booker will be re-directed to the redirectURI with booking UID as the bookingUid parameter aka my-app.com/bookings/[bookingUid].
- In the my-app.com/bookings/[bookingUid] route create a page that imports
useBookinghook, then extract bookingUid from URL parameter, and uses the hook to display booking information. BecauseuseBookinghook can return individual booking or an array of recurring bookings, you need to handle single booking and array of bookings cases separately:
import { useBooking } from "@calcom/atoms";
export default function Bookings(props: { calUsername: string; calEmail: string }) {
const router = useRouter();
const { isLoading, data: booking, refetch } = useBooking((router.query.bookingUid as string) ?? "");
return (
<>
{!Array.isArray(booking) ? (
<p>{booking.title}</p>
) : (
booking.map((recurrence) => <p key={recurrence.id}>{recurrence.title}</p>)
)}
</>
)
};An example implementation can be found here.
Reschedule URL
- Pass
my-app.com/bookings/rescheduleas the redirectURI. - When “Reschedule” is clicked, user will be re-directed to the redirectURI with rescheduled and eventTypeSlug query parameters
my-app.com/reschedule?rescheduleUid=buiaE8jHmNAxLrqitahCeL&eventTypeSlug=thirty-minutes - In the my-app.com/reschedule route create a page that extracts
rescheduleUidandeventTypeSlugfrom the query parameters and passes the to theBookeratom:
const rescheduleUid = (router.query.rescheduleUid as string) ?? "";
const eventTypeSlugQueryParam = (router.query.eventTypeSlug as string) ?? "";
<Booker
rescheduleUid={rescheduleUid}
eventSlug={eventTypeSlugQueryParam}
username={calUsername}
/>You only need rescheduleUid, eventSlug and username.
An example implementation can be found here.
Cancel URL
- Pass
my-app.com/bookings/cancelas the cancelURI. - In your app, create
my-app.com/bookings/cancel/[bookingUid]page where bookingUid will become path parameter. - In the page of my-app.com/cancel/[bookingUid] import useCancelBooking from atoms and get access to the cancel mutation
import { useCancelBooking } from "@calcom/atoms";
const { mutate: cancelBooking } = useCancelBooking({
onSuccess: () => {
refetch();
},
});- Create a cancel button that invokes mutation returned by the “useCancelBooking”. You have to pass id of the booking which you can get by fetching booking using "useBooking" hook by uid from the query params. Provide a suitable “cancellationReason”.
Because
useBookinghook can return individual booking or an array of recurring bookings, you need to handle single booking and array of bookings cases separately:
import { useBooking, useCancelBooking } from "@calcom/atoms";
...
const { isLoading, data: booking, refetch } = useBooking((router.query.bookingUid as string) ?? "");
const { mutate: cancelBooking } = useCancelBooking({
onSuccess: () => {
refetch();
},
});
...
return !Array.isArray(booking) ? (
<button
className="underline"
onClick={() => {
cancelBooking({
id: booking.id,
cancellationReason: "User request",
});
}}
>
Cancel
</button>
) : (
<>
{booking.map((recurrence) => (
<button
key={recurrence.id}
className="underline"
onClick={() => {
cancelBooking({
id: recurrence.id,
cancellationReason: "User request",
});
}}
>
Cancel
</button>
))}
</>
);An example implementation can be found here.
Last updated
On This Page