strapi-rrule-field
v0.0.1
Published
Adds a custom field type to create recurring rules.
Maintainers
Readme
strapi-rrule-field
Strapi v5 plugin that adds a Recurrence Rule custom field. Stores an RRuleSet string in a string column and provides a composite form UI in the Content Manager for building recurring schedules with exclusions and extra dates.
Features
- Frequency: Daily / Weekly / Monthly / Yearly
- Interval (every N units)
- Optional start date & time (DTSTART)
- Optional duration per occurrence (DURATION)
- End condition: never, on a date (UNTIL), or after N occurrences (COUNT)
- Weekday selection (Weekly only)
- Day-of-month selection (Monthly only)
- Excluded dates (EXDATE) (for holidays, exceptions)
- Extra one-off dates (RDATE)
- Live RRule string preview
Installation
yarn add strapi-rrule-fieldRegister the plugin in your Strapi app's config/plugins.ts:
export default {
'strapi-rrule-field': { enabled: true },
};Usage
In the Content-Type Builder, add a Custom field and select Recurrence Rule. The field is stored as a plain string (e.g. RRULE:FREQ=WEEKLY;BYDAY=MO,FR).
The stored value is a standard iCalendar RRuleSet string. Multi-line when DTSTART, DURATION, EXDATEs, or RDATEs are present:
DTSTART:20260101T090000Z
RRULE:FREQ=WEEKLY;BYDAY=MO,WE,FR;UNTIL=20261231T000000Z
DURATION:PT1H30M
EXDATE:20261225T000000Z
RDATE:20270101T000000ZMultiple schedules per content type
A single RRule field describes one recurring schedule (one start time, one duration). For content types that need multiple schedules with different times (e.g. Monday at 9am for 1 hour, Wednesday at 2pm for 30 minutes), use a Strapi repeatable component containing this field.
Consuming the stored value
Use the rrule package to parse the stored string. Strip the DURATION line first if present, as the rrule library does not handle it:
import { rrulestr } from 'rrule';
const lines = value.split('\n');
const durationLine = lines.find(l => l.startsWith('DURATION:'));
const rruleStr = lines.filter(l => !l.startsWith('DURATION:')).join('\n');
const rruleset = rrulestr(rruleStr, { forceset: true });
const occurrences = rruleset.all();Date handling / timezone note
The rrule library uses a "floating UTC" convention: all dates are stored with a UTC offset of zero but are intended to be interpreted as local calendar dates/times.
DTSTART carries the event start time (e.g. T090000Z = "9am, wherever you are"). EXDATE/RDATE are date-only and stored at UTC midnight.
When consuming occurrences, use UTC component accessors to avoid off-by-one errors in negative-offset timezones:
// safe in any timezone
const year = date.getUTCFullYear();
const month = date.getUTCMonth();
const day = date.getUTCDate();
const hours = date.getUTCHours();
const mins = date.getUTCMinutes();
// can return the wrong day/time in e.g. UTC-5
const day = date.getDate();This is only a concern on the consuming side. The plugin stores and hydrates dates correctly regardless of the editor's timezone.
Development
yarn build # build the plugin
yarn watch # watch mode
yarn watch:link # watch + link for local Strapi app development