Skip to main content

Working with Calendar (expo-calendar)

1. Requesting Calendar Permissions

Permission Scope Description
Calendar calendar.read Allows reading calendar events and details
Calendar calendar.write Allows creating and modifying calendar events

Example: Requesting Calendar Permissions

import * as Calendar from 'expo-calendar';

const getCalendarPermissions = async () => {
  const { status } = await Calendar.requestCalendarPermissionsAsync();
  if (status === 'granted') {
    console.log('Calendar permissions granted');
  } else {
    console.log('Calendar permissions denied');
  }
};

getCalendarPermissions();

2. Getting Calendars

Property Description Notes
id Unique identifier for the calendar Read-only
name Name of the calendar Editable
color Color associated with the calendar Hex color code or named color
type Type of calendar (e.g., LOCAL, EXCHANGE) Read-only
ownerAccount Owner account of the calendar Read-only
allowsModifications Indicates if calendar can be modified Boolean

Example: Fetching Calendars

import * as Calendar from 'expo-calendar';

const calendars = await Calendar.getCalendarsAsync();
console.log(calendars);
Note: You must request calendar permissions before fetching calendars.

3. Creating Calendar Events

Property Description Example Value
title Title of the event "Team Meeting"
startDate Start date and time of the event (ISO 8601) "2025-04-10T10:00:00Z"
endDate End date and time of the event (ISO 8601) "2025-04-10T11:00:00Z"
location Location of the event "Conference Room A"
description Description or notes for the event "Quarterly planning session"
calendarId ID of the calendar to create the event in "123456789"

Example: Creating a Calendar Event

import * as Calendar from 'expo-calendar';

const event = {
  title: 'Team Meeting',
  startDate: '2025-04-10T10:00:00Z',
  endDate: '2025-04-10T11:00:00Z',
  location: 'Conference Room A',
  description: 'Quarterly planning session',
  calendarId: '123456789'
};

const eventId = await Calendar.createEventAsync(event);
console.log('Event created with ID:', eventId);
Note: Ensure the calendar ID corresponds to a valid calendar accessible by the app.

4. Updating Events

Property Description Values
id Unique identifier for the event string
title Title of the event string
startDate Start date and time of the event Date
endDate End date and time of the event Date
location Location of the event string
description Description of the event string
calendarId ID of the calendar to which the event belongs string

Example: Updating an Event

import * as Calendar from 'expo-calendar';

const updateEvent = async () => {
  const eventId = '12345';
  const updatedEvent = {
    id: eventId,
    title: 'Updated Meeting',
    startDate: new Date('2026-04-15T10:00:00'),
    endDate: new Date('2026-04-15T11:00:00'),
    location: 'Conference Room B',
    description: 'Updated meeting description',
    calendarId: 'calendar-id'
  };

  await Calendar.updateEventAsync(eventId, updatedEvent);
};

updateEvent();

5. Deleting Events

Method Description Notes
deleteEventAsync Deletes an event from the calendar Requires event ID and calendar ID

Example: Deleting an Event

import { deleteEventAsync } from 'expo-calendar';

const eventId = '12345';
const calendarId = '67890';

await deleteEventAsync(eventId, calendarId);
Note: Ensure the event ID and calendar ID are valid before deletion.

6. Getting Events

Property Description Example
id Unique identifier for the event "12345"
title Title of the event "Team Meeting"
startDate Start date and time of the event "2025-04-10T10:00:00Z"
endDate End date and time of the event "2025-04-10T11:00:00Z"
calendarId ID of the calendar the event belongs to "cal-123"
location Location of the event "Conference Room A"
description Description or notes about the event "Quarterly planning session"

Example: Fetching Events from Calendar

import * as Calendar from 'expo-calendar';

const getEvents = async () => {
  const events = await Calendar.getEventsAsync(
    'cal-123',
    new Date('2025-04-10T00:00:00Z'),
    new Date('2025-04-11T00:00:00Z')
  );
  console.log(events);
};

getEvents();
Note: Ensure that the calendar ID is valid and accessible to the user.

7. Creating Reminders (iOS)

Property Description Values
title Title of the reminder string
calendarId ID of the calendar to create the reminder in string
startDate Start date and time of the reminder Date
endDate End date and time of the reminder Date
location Location associated with the reminder string
notes Additional notes for the reminder string
allDay Flag to indicate if the reminder is all-day boolean
reminderDate Date and time for the reminder alert Date

Example: Creating a Reminder

import * as Calendar from 'expo-calendar';

const createReminder = async () => {
  const calendarId = 'your-calendar-id';
  const reminder = {
    title: 'Meeting with team',
    calendarId,
    startDate: new Date(2025, 10, 15, 10, 0),
    endDate: new Date(2025, 10, 15, 11, 0),
    location: 'Conference Room A',
    notes: 'Discuss project timeline',
    allDay: false,
    reminderDate: new Date(2025, 10, 15, 9, 30),
  };

  try {
    const reminderId = await Calendar.createReminderAsync(reminder);
    console.log('Reminder created with ID:', reminderId);
  } catch (error) {
    console.error('Error creating reminder:', error);
  }
};
Note: On iOS, reminders must be created in a calendar that supports reminders. Ensure the calendar has the appropriate permissions.

8. Setting Event Recurrence

Property Values Description
recurrenceRule RRULE Defines the recurrence pattern using iCalendar RRULE format
recurrenceEnd Date End date for the recurring event
recurrenceCount number Number of times the event should repeat (alternative to end date)

Example: Setting Daily Recurrence

import { Calendar } from 'expo-calendar';

const event = {
  title: 'Daily Standup',
  startDate: new Date(2026, 5, 15, 9, 0),
  endDate: new Date(2026, 5, 15, 10, 0),
  recurrenceRule: {
    frequency: 'DAILY',
    interval: 1,
    endDate: new Date(2026, 5, 30),
  },
};

const eventId = await Calendar.createEventAsync(
  calendarId,
  event
);

Example: Weekly Recurrence with Count

const weeklyEvent = {
  title: 'Weekly Team Meeting',
  startDate: new Date(2026, 5, 15, 14, 0),
  endDate: new Date(2026, 5, 15, 15, 0),
  recurrenceRule: {
    frequency: 'WEEKLY',
    interval: 1,
    count: 10,
  },
};

const eventId = await Calendar.createEventAsync(
  calendarId,
  weeklyEvent
);
Note: The recurrenceRule object supports various frequency types like DAILY, WEEKLY, MONTHLY, and YEARLY. The interval property specifies the interval between occurrences (e.g., every 2 weeks). The count and endDate properties are mutually exclusive.

9. Adding Event Alarms

Property Values Description
alarmDate Date The date and time when the alarm should trigger. Must be a valid JavaScript Date object.
alarmType 'DISPLAY' | 'EMAIL' | 'SILENT' Specifies how the alarm should be delivered. 'DISPLAY' shows a notification, 'EMAIL' sends an email (if supported), and 'SILENT' triggers silently.
alarmOffset number Number of minutes before the event starts to trigger the alarm. Positive values mean the alarm triggers before the event.

Example: Adding an Event with Alarm

import * as Calendar from 'expo-calendar';

const event = {
  title: 'Team Meeting',
  startDate: new Date(2026, 5, 15, 10, 0),
  endDate: new Date(2026, 5, 15, 11, 0),
  alarms: [
    {
      alarmDate: new Date(2026, 5, 15, 9, 30),
      alarmType: 'DISPLAY',
      alarmOffset: 30,
    },
  ],
};

const eventId = await Calendar.createEventAsync(event);

10. Opening Calendar App

Property Description Notes
openCalendarAsync Opens the native calendar app Available on iOS and Android

Example: Opening Calendar App

import { openCalendarAsync } from 'expo-calendar';

await openCalendarAsync();

11. Getting Event Details

Property Description Example
id Unique identifier for the event "12345"
title Title of the event "Team Meeting"
startDate Start date and time of the event "2025-04-10T10:00:00Z"
endDate End date and time of the event "2025-04-10T11:00:00Z"
location Location of the event "Conference Room A"
description Description or notes about the event "Discuss Q2 goals and roadmap"
calendarId ID of the calendar this event belongs to "cal_abc123"

Example: Fetching Event Details

import { Calendar } from 'expo-calendar';

const getEventDetails = async (eventId) => {
  try {
    const event = await Calendar.getEventAsync(eventId);
    console.log('Event Title:', event.title);
    console.log('Start Date:', event.startDate);
    console.log('End Date:', event.endDate);
  } catch (error) {
    console.error('Error fetching event details:', error);
  }
};

getEventDetails('12345');
Note: Ensure that the user has granted necessary permissions to access calendar data before calling getEventAsync.

12. Filtering Events by Date

Property Description Values
startDate Date to start filtering from ISO 8601 string
endDate Date to end filtering at ISO 8601 string

Example: Filter Events by Date Range

import * as Calendar from 'expo-calendar';

const filterEvents = async () => {
  const events = await Calendar.getEventsAsync({
    startDate: '2025-01-01T00:00:00Z',
    endDate: '2025-01-31T23:59:59Z'
  });

  console.log(events);
};

Was this article helpful?