
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
@astrocal/react
Advanced tools
React SDK for Astrocal — Provider, hooks, and embeddable booking widget for React apps
React SDK for Astrocal — Provider, hooks, API client, and embeddable booking widget for React apps.
npm install @astrocal/react
# or
pnpm add @astrocal/react
For the widget component, also install the optional peer dependency:
npm install @astrocal/widget
Wrap your app (or a subtree) with AstrocalProvider to make the API client available via hooks:
import { AstrocalProvider } from "@astrocal/react";
function App() {
return (
<AstrocalProvider apiKey="sk_live_...">
<MySchedulingPage />
</AstrocalProvider>
);
}
Access the typed API client anywhere inside the provider:
import { useAstrocal } from "@astrocal/react";
function EventTypesList() {
const astrocal = useAstrocal();
const [eventTypes, setEventTypes] = useState([]);
useEffect(() => {
astrocal.eventTypes.list().then(({ data }) => setEventTypes(data));
}, [astrocal]);
return (
<ul>
{eventTypes.map((et) => (
<li key={et.id}>
{et.title} — {et.duration_minutes}min
</li>
))}
</ul>
);
}
Use the API client without React context:
import { AstrocalApiClient } from "@astrocal/react";
const client = new AstrocalApiClient({ apiKey: "sk_live_..." });
const { data: eventTypes } = await client.eventTypes.list();
const { slots } = await client.availability.query({
event_type_id: eventTypes[0].id,
start: "2026-03-01",
end: "2026-03-07",
timezone: "America/New_York",
});
The AstrocalWidget component wraps @astrocal/widget for seamless React integration.
Renders the booking calendar directly in your page:
import { AstrocalWidget } from "@astrocal/react";
function BookingPage() {
return (
<AstrocalWidget
eventTypeId="evt_abc123"
timezone="America/New_York"
colorScheme="light"
onBookingCreated={(booking) => {
console.log("Booked!", booking.id);
}}
/>
);
}
Wraps a trigger element that opens the widget as a modal on click:
import { AstrocalWidget } from "@astrocal/react";
function BookButton() {
return (
<AstrocalWidget eventTypeId="evt_abc123" mode="popup">
<button>Book a Meeting</button>
</AstrocalWidget>
);
}
| Prop | Type | Default | Description |
|---|---|---|---|
eventTypeId | string | — | Event type UUID (required) |
mode | "inline" | "popup" | "inline" | Render mode |
apiUrl | string | "https://api.astrocal.dev" | API base URL |
timezone | string | auto-detect | IANA timezone |
theme | ThemeConfig | — | CSS custom property overrides |
colorScheme | "light" | "dark" | "auto" | "auto" | Color scheme |
demo | boolean | false | Demo mode (mock data) |
onBookingCreated | (booking) => void | — | Booking success callback |
onError | (error) => void | — | Error callback |
onClose | () => void | — | Popup close callback |
className | string | — | Container CSS class |
style | CSSProperties | — | Container inline styles |
client.eventTypes.list(); // GET /v1/event-types
client.eventTypes.get(id); // GET /v1/event-types/:id
client.eventTypes.create(input); // POST /v1/event-types
client.eventTypes.update(id, input); // PATCH /v1/event-types/:id
client.eventTypes.delete(id); // DELETE /v1/event-types/:id
client.bookings.list(params?) // GET /v1/bookings
client.bookings.get(id) // GET /v1/bookings/:id
client.bookings.cancel(id, reason?) // POST /v1/bookings/:id/cancel
client.bookings.reschedule(id, input) // POST /v1/bookings/:id/reschedule
client.availability.query(params); // GET /v1/availability
client.webhooks.list() // GET /v1/webhooks
client.webhooks.get(id) // GET /v1/webhooks/:id
client.webhooks.create(input) // POST /v1/webhooks
client.webhooks.update(id, input) // PATCH /v1/webhooks/:id
client.webhooks.delete(id) // DELETE /v1/webhooks/:id
client.webhooks.listDeliveries(id, params?) // GET /v1/webhooks/:id/deliveries
client.webhooks.retryDelivery(whId, delId) // POST /v1/webhooks/:id/deliveries/:id/retry
client.usage.get() // GET /v1/usage
client.usage.summary(period?) // GET /v1/usage/summary
client.apiKeys.list(); // GET /v1/api-keys
client.apiKeys.create(input); // POST /v1/api-keys
client.apiKeys.revoke(id); // DELETE /v1/api-keys/:id
All API errors throw AstrocalError:
import { AstrocalError } from "@astrocal/react";
try {
await client.eventTypes.get("invalid_id");
} catch (err) {
if (err instanceof AstrocalError) {
console.log(err.status); // 404
console.log(err.code); // "not_found"
console.log(err.message); // "Event type not found"
}
}
Works with both App Router and Pages Router. For App Router, the provider and widget include "use client" directives automatically.
// app/layout.tsx
import { AstrocalProvider } from "@astrocal/react";
export default function RootLayout({ children }) {
return (
<AstrocalProvider apiKey={process.env.NEXT_PUBLIC_ASTROCAL_KEY!}>{children}</AstrocalProvider>
);
}
All types are exported for use in your application:
import type {
EventType,
Booking,
AvailabilitySlot,
PaginatedResponse,
AstrocalClient,
} from "@astrocal/react";
MIT
FAQs
React SDK for Astrocal — Provider, hooks, and embeddable booking widget for React apps
We found that @astrocal/react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.