react-calendly is a React component library designed to simplify the integration of Calendly scheduling pages into React applications. It provides high-level components like InlineWidget, PopupWidget, and PopupButton for embedding various Calendly layouts, as well as the useCalendlyEventListener hook for programmatic interaction with Calendly events within the iframe. The library is actively maintained, with its current stable version being 4.4.0. Releases occur frequently, typically addressing bug fixes and introducing new prefill options or minor feature enhancements. Key differentiators include its abstraction over raw Calendly embed scripts, direct support for React's component lifecycle and hooks, and built-in handling for common embedding challenges like loading states and event listening. It relies on React's Portal feature for modal rendering, requiring explicit rootElement configuration for popup widgets.
npm install react-calendlyVerified import paths — ran on the pinned version, not inferred.
This quickstart embeds an InlineWidget for a Calendly scheduling page, demonstrating basic usage within a React component. Make sure to replace the placeholder URL with your actual Calendly link.
Migrate from `<CalendlyEventListener>` to `useCalendlyEventListener()` hook for event handling. For example, replace `<CalendlyEventListener onEventScheduled={handler} />` with `useCalendlyEventListener({ onEventScheduled: handler });`.Ensure your project's `react` and `react-dom` packages are updated to version `16.8.0` or higher to satisfy peer dependency requirements.
Always provide `rootElement={document.getElementById('root')}` or another valid DOM element as a prop to `PopupWidget` and `PopupButton`.Update to `react-calendly@4.0.1` or newer. For custom prefill options, ensure values are URI-encoded before passing them, for example, `encodeURIComponent('my+email@example.com')`.To customize the loading experience, pass your own `LoadingSpinner` React component to the `InlineWidget` or other Calendly components, e.g., `<InlineWidget LoadingSpinner={MyCustomSpinner} ... />`.Replace the `CalendlyEventListener` component with the `useCalendlyEventListener` hook, which is the correct API for event handling since v4.0.0.
Ensure you pass a valid DOM element to the `rootElement` prop, typically `rootElement={document.getElementById('root')}` or the ID of your application's root div.Upgrade `react-calendly` to v4.0.1 or newer. Additionally, ensure that any custom prefill values are correctly URI-encoded, especially for special characters.
Update your `react-calendly` package to version v2.2.2 or later to resolve the loading spinner persistence issue.