Browse SDK

plandalf.mount()

Mount an offer in an element.

Implemented by the browser object; parameter and return types follow the delegated class declaration.

Call this after plandalf.ready(). The browser wrapper can return undefined before initialization.

Signature

plandalf.mount(
  target: HTMLElement | string,
  slug: string,
  opts?: MountOptions,
): FlowHandle<Flow>

Arguments

NameTypeMeaning
targetHTMLElement | stringElement or CSS selector to mount into.
slugstringPublished offer slug.
opts?MountOptionsInline mount options passed through to the class. The browser wrapper declares this argument as any and passes it to the typed class method.

Example

mount.js
plandalf.ready(async () => {
  const handle = plandalf.mount('#checkout', 'upgrade', {
    promo: 'early-bird',
    metadata: { source: 'pricing-page' },
  })
  const flow = await handle
  console.log(flow.id, flow.state)
})

Mount options

These fields come from MountOptions. The current mount() implementation forwards user, promo, properties, and metadata; the other three fields are declared but are not forwarded to checkout.

FieldTypeMeaning
continuity?ContinuityScopeDeclared in the type; the current mount() implementation does not forward it.
metadata?Record<string, string>Per-call Stripe-customer metadata. Eager strings only.
mode?"test" | "live" | "preview"Declared in the type; the current mount() implementation does not forward it.
promo?stringPromo slug; the SDK resolves the active tier internally and applies its price.
properties?Record<string, unknown>Per-call form-field prefill. Wins over PlandalfConfig.properties on overlap.
session?string | nullDeclared in the type; the current mount() implementation does not forward it.
user?stringPer-call JWT override — overrides the global identify() for this mount.

Resolved flow

Awaiting the handle gives a Flow, after the inline checkout mounts. Its top-level fields are:

FieldTypeMeaning
harnessHarnessDefinitionThe flow's step and block definition.
idstringID for this flow instance.
stateFlowStateCurrent status, step, and context.
templateFlowTemplateOffer template used by the flow.

The flow.state object contains:

FieldTypeMeaning
contextFlowContextCustomer, cart, and payment context.
currentStepstring | nullCurrent step ID, or null.
error?ErrorCurrent error, if any.
statusFlowStatusCurrent flow lifecycle status.
stepDataRecord<string, unknown>Data stored by step ID.

The flow also provides methods such as close() and on().

Returns

FlowHandle<Flow>

Behaviour

The handle resolves when the flow has mounted, rather than when a purchase completes.

All plandalf methods

Feature detail