GlassHouse Docs Support
Reference

JavaScript API reference

The options and methods used by the browser and server integrations.

mountGlassHouse(options)

Returns Promise<GlassHouseEmbed>. Importing the entry is safe during server rendering; call the function in the browser after the target element mounts.

OptionUse
target · requiredAn empty, connected element or CSS selector.
endpoint · requiredSame-origin server base path, usually /api/glasshouse/.
productIdCurrent purchasable product ID, or null.
appearancedark (default) or light.
launchhelp (default), chat or visual_layout.
presentationHelp-menu copy, contact URL and optional product selectors.
onCartChangeCallback with the store’s CartResult.

Mount one GlassHouse interface per document.

Instance methods

MethodEffect
updateContext({ productId })Change the current product without remounting the interface. Pass null for a general page.
destroy()Unmount the interface and release its listeners and state.

Product-card overlays

Opt in with selectors that match your storefront. Put data-product-id on each card and use the same ID as the catalogue.

Product card
<article class="plant-card" data-product-id="lavender-2l">
  <!-- Your existing product content -->
</article>
Presentation options
presentation: {
  productCardSelector: '.plant-card',
  productNameSelector: '.plant-card__name',
  productImageSelector: '.plant-card__image',
  contactUrl: '/contact',
}

Package exports

ImportExports
@superseeded/glasshousemountGlassHouse, browser option types.
@superseeded/glasshouse/style.cssThe interface stylesheet.
@superseeded/glasshouse/servercreateGlassHouseHandler, registerGlassHouseStore.
@superseeded/glasshouse/nodecreateNodeHandler.
@superseeded/glasshouse/typesStoreAdapter, StoreProduct, ShopperContext, CartResult and UI contracts.
@superseeded/glasshouse/coreDeterministic product, recommendation and layout functions.

Server options

createGlassHouseHandler(options) returns an asynchronous Request/Response handler.

OptionUse
originRequired canonical storefront origin, without a trailing slash or path.
merchantTokenRequired server-held merchant credential.
adapterRequired store catalogue and optional cart methods.
resolveShopper, rateLimit, consumeNonceRequired callbacks explained in the server guide.
basePathDefaults to /api/glasshouse. Match the browser endpoint and server routing.
onErrorOptional server-side error handler for your logging system.
Advanced service configuration

agentUrl overrides the default SuperSeeded service URL. callbackKeys overrides the trusted public signature-verification keys. Use these only for an intentionally configured service environment.

Tab to a result, then press Enter to open it.