Mastering Recurring Schedules with RRule
A 4-minute primer on RRule with a live tester link to craft and validate recurring schedules fast.
TL;DR
- RRule is the calendar standard (RFC 5545) for recurring events.
- Use the live tester to validate rules: RRule demo.
- Keep rules simple: FREQ + INTERVAL + COUNT/UNTIL + BYDAY.
- Show users a human summary and a short preview before saving.
Quickstart
import { RRule } from 'rrule'
const rule = RRule.fromString('FREQ=WEEKLY;INTERVAL=1;COUNT=8;BYDAY=MO,WE')
const occurrences = rule.all() // Dates for 8 Mondays/Wednesdays
console.log(rule.toText()) // "every week on Monday, Wednesday, 8 times"Test RRule Live
Paste your rule into the official playground to see occurrences instantly: RRule Demo Tester. Copy the final string back into your app.
Patterns to Copy
// Weekdays until year-end
RRULE:FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR;UNTIL=20261231
// First Monday of every month (6 times)
RRULE:FREQ=MONTHLY;BYDAY=+1MO;COUNT=6
// Every 2 weeks on Tue/Thu (10 occurrences)
RRULE:FREQ=WEEKLY;INTERVAL=2;BYDAY=TU,TH;COUNT=10Practical Tips
- Cap COUNT (e.g., < 365) to avoid massive result sets.
- Store both the RRule string and the computed end date.
- Render a human summary (
rule.toText()) plus a 3-occurrence preview. - Validate input: for WEEKLY require BYDAY; require COUNT or UNTIL for long spans.
- Timezone: keep DTSTART in UTC; convert to the userβs TZ when displaying.
Conclusion
RRule removes guesswork from recurring schedules. Start simple, validate with the live tester, and always show users what will happen before you create events.
Real-World Example: ShiftCare
A practical application of RRule is ShiftCare, a staff and booking management system. It uses RRule extensively to:
- Generate recurring shifts for staff members across months
- Auto-detect conflicts between overlapping bookings
- Provide a calendar view with color-coded shift types
- Enable users to edit recurring patterns or individual occurrences
ShiftCare on GitHub showcases how to integrate RRule into a production scheduling system with Prisma, Next.js, and ShadCN UI.