Skip to main content

Controller API

Use initializeSpaazaElements() to set up the controller and mount components. Returns Promise<SpaazaController>.

InitOptions

PropertyTypeRequiredDescription
targetstringYesCSS selector (e.g., '#spaaza-elements')
configSpaazaConfigYesAPI and authentication configuration
pageNamestringNoPage name to load (default: "home")
campaignIdnumberNoCampaign ID. Activates the detail view.
voucherIdnumberNoVoucher ID. Activates the detail view.
businessIdnumberNoFilter page content by store. From user.home_store.home_store_id.
componentBaseUrlstringNoBase URL for web component bundles
customZonesCustomZonesOptionsNoCustom zones for voucher and membercard display. See Custom Zones.
handlerOverridesobjectNoDisable automatic handling for specific operations. See Handler Overrides.

SpaazaConfig

PropertyTypeRequiredDescription
originstringYesAPI origin (https://api.spaaza.com production, https://apistage0.spaaza.com staging)
auth.sessionKeystringYesSession key from login
auth.userIDstringYesUser ID from login
auth.myPriceAppHoststringYesYour Spaaza app hostname (e.g., yourapp.spaaza.com)

Controller Methods

The controller returned by initializeSpaazaElements() provides:

MethodDescription
parseImageLink(imageLink)Parse image_link string. See parseImageLink() for the full return-value table.
refresh()Refresh current view (re-fetches data)
const controller = await initializeSpaazaElements({ ... });

// Refresh current view
await controller.refresh();