Skip to content

useConfig

Holds the merged configuration of a calendar.

ts
import { useConfig } from "@zaptime/core";

const { config, setConfig } = useConfig(calendarId?);

Set config

Merges the given config over the core defaults and stores it for the calendar. In a headless setup you call it once during initialization with the remote configuration merged under your local values; see Getting started.

ts
setConfig({
  token: "<API_TOKEN>",
  locale: { preset: "de" },
  theme: { mode: "dark" },
});

Calling setConfig again with a changed locale.preset or timezone-related values triggers a refetch of the days through the calendar's watcher.

Config

A computed ref with the current ZaptimeConfig.

ts
config.value.token;
config.value.locale?.texts?.chooseDate;
config.value.redirectAfterBookingUrl;

The available keys are listed in the config reference. In a headless UI the ones you will read most are locale.texts, locale.confirmationForm, theme, hideLocation, profileImage, redirectAfterBookingUrl and externalBooking.

Merge helper

mergeObjects(base, override) is exported for deep-merging the remote configuration with your local config. Local keys win, including empty strings.

ts
import { mergeObjects } from "@zaptime/core";

const merged = mergeObjects({ ...remote.configuration }, { ...localConfig });