Configuration
Start with working hours and a meeting length. Add the other options as your booking rules grow. The same basic options work across all three generators; the extra multi-day and availability options are listed at the bottom.
import { generateTimeslots } from 'timeslottr'
const slots = generateTimeslots({
day: '2024-03-15',
timezone: 'America/New_York',
range: { start: '09:00', end: '10:00' },
slotDurationMinutes: 30,
})
// Two slots: 09:00–09:30 and 09:30–10:00 in New Yorkrange and slotDurationMinutes are required. Time-only boundaries also need
a date, usually supplied by day. An explicit timezone keeps calendar inputs
consistent across browsers and servers.
Working hours and dates
Choose when the schedule runs.
| Option | Type | Default | Description |
|---|---|---|---|
range | TimeslotRangeInput | required | Start and end boundaries for slot generation. Accepts Dates, ISO strings, or time-only strings like "09:00". |
slotDurationMinutes | number | required | Length of each slot in minutes. Must be positive. |
day | Date | string | none | Calendar date to anchor time-only boundaries, e.g. day: '2024-03-15' with range: { start: '09:00', end: '17:00' }. |
timezone | string | none | IANA timezone id (e.g. "America/New_York", "UTC"). Controls calendar dates and time-only boundaries. Without it, the runtime local timezone is used. |
Slot starts and breaks
Control how often meetings can start and which parts of the window are usable.
| Option | Type | Default | Description |
|---|---|---|---|
slotIntervalMinutes | number | slotDurationMinutes | Step between consecutive slot starts. Set lower than the duration to create overlapping slots. |
bufferBeforeMinutes | number | 0 | Minutes trimmed from the start of the usable window before generating slots. |
bufferAfterMinutes | number | 0 | Minutes trimmed from the end of the usable window before generating slots. |
excludedWindows | TimeslotRangeInput[] | none | Sub-ranges to exclude (lunch breaks, blackouts). Overlapping exclusions are merged automatically. |
Leftover time at the edges
By default, only full-length slots are returned. To allow a shorter final slot,
keep includeEdge: true and lower minimumSlotDurationMinutes. For example,
a 09:00–09:45 window with a 30-minute duration and a 15-minute minimum can
return 09:00–09:30 plus 09:30–09:45 with start alignment.
| Option | Type | Default | Description |
|---|---|---|---|
alignment | 'start' | 'end' | 'center' | 'start' | How to handle leftover time that doesn’t fill a complete slot. 'start' discards at the end, 'end' aligns backward from the range end, 'center' distributes leftover on both sides. |
minimumSlotDurationMinutes | number | slotDurationMinutes | Minimum duration for partial/edge slots. Only relevant when includeEdge is true. |
includeEdge | boolean | true | Whether to include truncated edge slots (cut short by the range boundary or an exclusion) when they meet the minimum duration. |
Booking limits and labels
Limit which results are offered and add a display label if needed.
| Option | Type | Default | Description |
|---|---|---|---|
maxSlots | number | none | Maximum slots per call for single-day generators, or per day for generateDailyTimeslots. |
minimumNoticeMinutes | number | none | Lead time before a slot can be booked. Slots starting before now + minimumNoticeMinutes are dropped. Must be non-negative. |
maximumAdvanceDays | number | none | How far ahead bookings are allowed, in whole calendar days. Slots starting at or after the same wall-clock time that many days from now (in timezone) are dropped. Must be a positive integer. |
now | Date | string | new Date() | Reference “current time” for the two options above. Set it to make output deterministic, or to gate against a server clock. Ignored when neither option is set. |
labelFormatter | (slot, index, durationMinutes) => string | none | Callback to attach a custom label to each slot’s metadata. Return undefined to skip. |
The booking-window options apply to every generator. Filtering looks at each
slot’s start time, and the bookable span is half-open: a slot starting exactly at
the notice boundary is kept, one starting exactly at the advance cutoff is not.
Unbookable slots are removed before maxSlots is applied, so the cap counts
bookable slots only. maximumAdvanceDays alone does not remove past slots;
set minimumNoticeMinutes: 0 as well to exclude starts before now. See Booking windows.
Additional DailyTimeslotConfig options
Use these when repeating a schedule across a date range.
generateDailyTimeslots() accepts all of the above (except day, which is set
automatically per day), plus:
| Option | Type | Default | Description |
|---|---|---|---|
range | TimeslotRangeInput | Map<Weekday, TimeslotRangeInput | null> | required | Either a single range applied to every day, or a Map for per-weekday schedules. Weekdays absent from the map are skipped. |
maxDays | number | 10000 | Safety limit on the number of calendar days to iterate, so a bad period can’t loop forever. |
Additional AvailableTimeslotConfig options
Use these when meetings must fit around existing events.
generateAvailableTimeslots() accepts all single-day options, plus:
| Option | Type | Default | Description |
|---|---|---|---|
busy | TimeslotRangeInput[] | none | Booked events to subtract from availability (block everyone). |
participantsBusy | TimeslotRangeInput[][] | none | Per-person busy sets. When present, results are narrowed to windows where every participant is free. |
An empty inner list in participantsBusy means that person is free for the
whole window. For a complete example, follow the
availability guide.