Integration

Install & integrate

There is no separate npm package. Integrate via the hosted embed, iframes, or plain HTTP from your backend and frontend.

No @baas/sdk

Examples in older docs referred to a fictional SDK. Use fetch, axios, or your HTTP client against your deployment's /api/* routes.

Option A — Hosted embed (fastest)

Ship a full booking UI without building forms: open /embed/[tenant_id]?key=baas_publishable_…&widget=WIDGET_CONFIG_ID in an iframe or new window. Optional query params depend on your widget configuration.

iframe example
<iframe
  src="https://YOUR_APP_URL/embed/YOUR_TENANT_ID?key=baas_publishable_xxx&widget=YOUR_WIDGET_ID"
  width="100%"
  height="720"
  style="border:0;border-radius:12px"
  title="Bookings"
/>

Theme and copy are controlled from the dashboard under widget settings. See Widget & styling.

Option B — Custom UI (headless)

Call widget endpoints from your app: list availability with GET /api/widget/availability, create bookings with POST /api/widget/booking, and redirect customers to the Mollie payment page when the API returns a checkout URL.

Minimal fetch (availability)
const params = new URLSearchParams({
  key: process.env.NEXT_PUBLIC_BAAS_PUBLISHABLE_KEY,
  resource_id: resourceId,
  start_date: '2025-06-01',
  end_date: '2025-06-30',
})
const res = await fetch(`${process.env.NEXT_PUBLIC_APP_URL}/api/widget/availability?${params}`)
const data = await res.json()

Secrets

Never put a baas_server_secret_ key in frontend code. Server-only routes belong on your backend.

Environment variables (typical)

  • NEXT_PUBLIC_APP_URL — origin of this BaaS deployment (used in links and client-side fetch).
  • NEXT_PUBLIC_BAAS_PUBLISHABLE_KEY — your publishable key for browser/widget calls (name is your convention; not required by the framework).