# Calendar

> Calendars, events with RFC 5545 recurrence (RRULE, EXDATE and per-occurrence overrides) and attendees, working hours, out-of-office and focus-time blocks, and a free/busy query that counts approved leave. Series expand in TypeScript with the reminders block's expandRule and in SQL for free/busy; a share link serves an iCal feed.

- Category: Scheduling
- Module: `calendar`
- Modes: `managed`, `custom`
- Docs: https://bettersupabase.com/docs/blocks/calendar
- Page: https://bettersupabase.com/blocks/calendar

## Install

```bash
npx better-supabase add calendar
```

The command also installs `updated-at`, `memberships`, `permissions`, `recurrence`.

## Configure

Add the block to `better-supabase.config.ts`:

```ts
import { defineConfig } from "better-supabase/config";

export default defineConfig({
  blocks: {
    // Required by calendar; add installs them too.
    "updated-at": {},
    memberships: {},
    permissions: {},
    recurrence: {},
    // Modes: "managed", "custom". The default is "managed".
    calendar: { mode: "managed" },
  },
});
```

## Client

The React hooks are the registry item `@better-supabase/use-calendar` (`npx shadcn add @better-supabase/use-calendar`). They return data and actions and render no UI. Source: https://github.com/ScaleDockHQ/better-supabase/blob/main/packages/registry/items/hooks/use-calendar.ts

## Events

- `calendar.created`
- `calendar_event.created`
- `calendar_event.purged`
- `calendar_event.updated`

## Related blocks

Requires: [memberships](https://bettersupabase.com/blocks/memberships.md), [permissions](https://bettersupabase.com/blocks/permissions.md), [recurrence](https://bettersupabase.com/blocks/recurrence.md)

Works with: [share-links](https://bettersupabase.com/blocks/share-links.md), [reminders](https://bettersupabase.com/blocks/reminders.md), [outbox](https://bettersupabase.com/blocks/outbox.md), [leave](https://bettersupabase.com/blocks/leave.md), [organizations](https://bettersupabase.com/blocks/organizations.md)

## Recipes

- [Calendar view](https://bettersupabase.com/recipes/calendar-view.md): A month and week calendar of events with a dialog to add one.
- [Record calendar](https://bettersupabase.com/recipes/record-calendar.md): Rows on a month grid by a date column, with the month in the URL and a count of rows without a date.
- [Record timeline](https://bettersupabase.com/recipes/record-timeline.md): Rows as bars from a start date to an end date over four weeks, with a lane per assignee.
- [Record Gantt chart](https://bettersupabase.com/recipes/record-gantt.md): A row per record grouped by its parent, with a bar for its planned dates and a marker for rows without dates.
