Open Source • MIT License • v0.1.1

The Headless Booking Primitive

Production-grade scheduling infrastructure for developers. Drop-in slot engine, Drizzle ORM schema, and copy-paste React components. Ship a full booking system in hours, not weeks.

npmnpm install @thebookingkit/core
route.ts
// Server action — zero config required
import { getAvailableSlots } from "@thebookingkit/core"

const slots = getAvailableSlots(
  // RRULE-based availability windows
  rules,    // AvailabilityRuleInput[]
  overrides, // date-specific changes
  bookings,  // existing confirmed bookings
  range,     // { start: Date, end: Date }
  "America/New_York",
  {
    duration: 30,       // minutes
    bufferBefore: 5,
    bufferAfter: 5,
  }
)

// slots → Slot[] with localStart,
//   startTime, endTime — ready to render
slots.length // → 22 available
623
Unit Tests
5
Packages
21+
UI Components
Interactive Demo

Live Booking Flow

A real barber shop booking system — Fade & Shave Barbershop — powered entirely by @thebookingkit/core. All slot computation runs server-side using pure functions.

Fade & Shave Barbershop123 Main Street, Brooklyn, NY • America/New_York
1
Service
2
Date & Time
3
Details
4
Confirm

Choose a Service

✂️

Classic Haircut

30 min$35

Precision cut with clippers and scissors, includes hot towel finish.

🧔

Beard Trim & Shape

20 min$20

Professional beard sculpting with straight razor edge-up.

Haircut + Beard Combo

45 min$50

Full haircut with beard trim and shape. Our most popular service.

Custom questions
🪒

Hot Towel Shave

30 min$30

Traditional straight razor shave with hot towel treatment and aftershave.

👦

Kids Cut (12 & under)

20 min$22

Patient and fun haircuts for the little ones.

Custom questions
👑

Deluxe Grooming Package

75 min$85

Haircut, beard trim, hot towel shave, and scalp massage. The full experience.

Custom questions
Core Engine

Scheduling Primitives

Interactive demonstrations of the scheduling engine. Every computation runs server-side using the same pure functions you would use in your app.

Computing slots...

Team Scheduling

Multi-Provider Availability

getTeamSlots() and assignHost() compute availability across multiple providers with intelligent assignment.

MJ
Marcus JohnsonHead Barber

Mon-Fri, 9am-6pm

0 bookings this week
DW
Darius WellsSenior Barber

Tue-Sat, 10am-7pm

0 bookings this week
EC
Elena CruzBarber

Mon, Wed, Fri-Sat, 11am-5pm

0 bookings this week
Assignment Strategy

Union of all member slots. assignHost() picks the next barber based on booking count and priority.

Available Slots for 2026-03-10
Computing availability...
// Compute team availability const slots = getTeamSlots( members, range, tz, { duration: 30 }, "round_robin" ) // Assign next host const host = assignHost( slots[0].availableMembers, bookingCounts )
Advanced Capabilities

Everything Booking Systems Need

Six advanced scheduling primitives, each with interactive demos backed by live server action calls to @thebookingkit/core.

Recurring Bookings
Generate occurrence series for weekly, biweekly, or monthly recurring appointments.
Occurrences:6
generateOccurrences(input)
Seat-Based Events
Group events and classes with per-slot seat capacity and live availability tracking.
Capacity: 10
Booked: 6
computeSeatAvailability(maxSeats, attendees)
Walk-In Queue
Accept walk-in customers alongside scheduled bookings with live wait time estimation.
Queue: 3 ahead
Avg: 30 min
estimateWaitTime(queue, avgMinutes)
Routing Forms
Intake forms that route customers to the right event type based on their answers.
What service do you need?
evaluateRoutingRules(form, responses)
Payment Hooks
Tiered cancellation policies with automatic fee calculation. Integrates with any payment provider.
Cancel 6h before booking
evaluateCancellationFee(policy, now, start, amount)
Kiosk Mode
Tablet-optimized check-in kiosks with configurable views, walk-in support, and provider management.
resolveKioskSettings(partial)
Package Ecosystem

Five Focused Packages

Each package has a single responsibility and clear boundaries. Use only what you need.

@thebookingkit/corev0.1.1Browser / Edge / Node

The scheduling math engine. Framework-agnostic pure functions for slot computation, team scheduling, recurring bookings, routing forms, payments, kiosk, and walk-in.

getAvailableSlotsgetTeamSlotsassignHostcomputeBookingLimitsgenerateOccurrencescomputeSeatAvailability+5 more
import { getAvailableSlots } from "@thebookingkit/core";

const slots = getAvailableSlots(
  rules, overrides, bookings,
  { start, end }, timezone,
  { duration: 30, bufferBefore: 5 }
);
@thebookingkit/serverv0.1.1Node / Edge

Backend infrastructure: auth adapters, webhook signing, API key management, email templates, background job adapters, booking tokens, and multi-tenancy utilities.

AuthAdapterEmailAdapterJobAdapterCalendarAdaptersignWebhookverifyWebhook+2 more
import { withSerializableRetry } from "@thebookingkit/server";

// Automatically retries on SQLSTATE 40001
const booking = await withSerializableRetry(
  () => db.transaction(createBooking)
);
@thebookingkit/dbv0.1.1Node (Postgres)

Drizzle ORM schema and migrations for PostgreSQL 15+. Includes btree_gist extension for EXCLUDE constraints, audit triggers, and GDPR helpers.

bookingsproviderseventTypesavailabilityRulesbookingEventsschema+1 more
import { db } from "@thebookingkit/db";
import { bookings } from "@thebookingkit/db/schema";

// Drizzle ORM — type-safe queries
const upcoming = await db
  .select()
  .from(bookings)
  .where(eq(bookings.status, "confirmed"));
@thebookingkit/d1v0.1.1Cloudflare D1 / Edge

Cloudflare D1 (SQLite) adapter with UTC date codec, advisory locking for double-booking prevention, and weekly schedule conversion utilities.

D1DateCodecd1DayQueryD1BookingLockweeklyScheduleToRulesrunMigrations
import { D1BookingLock } from "@thebookingkit/d1";

// Advisory lock prevents double-bookings
// on Cloudflare D1 (no SKIP LOCKED)
const lock = new D1BookingLock(db);
await lock.withLock(slotKey, createBooking);
@thebookingkit/cliv0.1.1CLI Tool

Scaffolding CLI for adding components, running database migrations, and initializing new projects. Uses the registry.json component manifest.

npx thebookingkit initnpx thebookingkit addnpx thebookingkit migratenpx thebookingkit list
# Scaffold a new project
npx thebookingkit init my-booking-app

# Add a UI component from the registry
npx thebookingkit add booking-calendar

# Run database migrations
npx thebookingkit migrate
UI Component Library

21+ Copy-Paste Components

React components built on shadcn/ui conventions. Add them to your project with the CLI. You own the source — customize freely.

Install any component
Components are copied directly into your project — not imported from npm. They use shadcn/ui primitives and are fully TypeScript-typed.
npx thebookingkit add <name>
Booking Flow
booking-calendar
Date picker with availability state and timezone display
npx thebookingkit add booking-calendar
slot-picker
Time slot grid with morning/afternoon/evening grouping
npx thebookingkit add slot-picker
booking-form
Multi-step form with validation and custom questions
npx thebookingkit add booking-form
booking-confirm
Confirmation summary with all booking details
npx thebookingkit add booking-confirm
booking-success
Success screen with booking ID and calendar add
npx thebookingkit add booking-success
Service Selection
service-card
Individual service card with price, duration, and description
npx thebookingkit add service-card
service-grid
Responsive grid layout for service listings
npx thebookingkit add service-grid
service-badge
Small badge for seat count, custom questions, or status
npx thebookingkit add service-badge
Team & Providers
provider-card
Provider profile card with avatar and availability indicator
npx thebookingkit add provider-card
provider-selector
Dropdown or grid for multi-provider selection
npx thebookingkit add provider-selector
team-availability-grid
Side-by-side availability view for all team members
npx thebookingkit add team-availability-grid
Admin & Dashboard
bookings-table
Full admin table with status filters and action buttons
npx thebookingkit add bookings-table
booking-stats
Stat cards for total, upcoming, pending, and resolved counts
npx thebookingkit add booking-stats
schedule-editor
Drag-to-set weekly schedule with RRULE output
npx thebookingkit add schedule-editor
override-calendar
Calendar for adding availability overrides and blocked dates
npx thebookingkit add override-calendar
Queue & Walk-In
walk-in-queue
Live queue display with position numbers and wait estimates
npx thebookingkit add walk-in-queue
check-in-kiosk
Full-screen kiosk check-in flow for tablets
npx thebookingkit add check-in-kiosk
wait-time-badge
Compact badge showing estimated wait time
npx thebookingkit add wait-time-badge
Utilities
timezone-selector
Searchable timezone dropdown with offset display
npx thebookingkit add timezone-selector
status-badge
Color-coded status badge for all booking states
npx thebookingkit add status-badge
copy-snippet
Syntax-highlighted code block with copy-to-clipboard button
npx thebookingkit add copy-snippet
embed-generator
UI for generating embed snippets with live preview
npx thebookingkit add embed-generator
Architecture

Three-Layer Design

Clean separation between scheduling logic, backend infrastructure, and database schema. Swap any external dependency without touching your booking logic.

Layer 1
@thebookingkit/core

Pure scheduling math — no side effects, no I/O, no framework dependencies. Works in browser, Node, and Cloudflare Workers.

getAvailableSlotsgetTeamSlotsassignHostgenerateOccurrencescomputeSeatAvailabilityestimateWaitTimeevaluateRoutingRulesevaluateCancellationFee
Layer 2
@thebookingkit/server

Backend infrastructure with swappable adapters. Handles auth, email, webhooks, background jobs, and booking tokens.

AuthAdapterEmailAdapterJobAdapterCalendarAdaptersignWebhookwithSerializableRetrycreateApiKeybookingTokens
Layer 3
@thebookingkit/db

Drizzle ORM schema for PostgreSQL 15+. EXCLUDE USING gist prevents double-bookings at the database level. SERIALIZABLE transactions with retry.

bookingsproviderseventTypesavailabilityRulesbookingEventsEXCLUDE USING gistbtree_gist

Adapter Swap Table

AdapterPurposeDefaultAlternatives
AuthAdapterAuthentication & session managementNextAuth.js 5.x
ClerkSupabase AuthLuciaCustom JWT
EmailAdapterTransactional email deliveryResend
SendGridAWS SESPostmarkNodemailer
JobAdapterBackground jobs & queuesInngest 3.x
Trigger.devBullMQVercel Cron
CalendarAdapterExternal calendar syncGoogle Calendar OAuth
Apple Calendar (CalDAV)OutlookNo-op
StorageAdapterSecrets & encrypted configEnv var key
AWS KMSHashiCorp VaultVercel Env
SmsAdapterSMS notifications & remindersTwilio
VonageAWS SNSNo-op