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
| Name | Type | Meaning |
|---|---|---|
target | HTMLElement | string | Element or CSS selector to mount into. |
slug | string | Published offer slug. |
opts? | MountOptions | Inline 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.
| Field | Type | Meaning |
|---|---|---|
continuity? | ContinuityScope | Declared 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? | string | Promo 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 | null | Declared in the type; the current mount() implementation does not forward it. |
user? | string | Per-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:
| Field | Type | Meaning |
|---|---|---|
harness | HarnessDefinition | The flow's step and block definition. |
id | string | ID for this flow instance. |
state | FlowState | Current status, step, and context. |
template | FlowTemplate | Offer template used by the flow. |
The flow.state object contains:
| Field | Type | Meaning |
|---|---|---|
context | FlowContext | Customer, cart, and payment context. |
currentStep | string | null | Current step ID, or null. |
error? | Error | Current error, if any. |
status | FlowStatus | Current flow lifecycle status. |
stepData | Record<string, unknown> | Data stored by step ID. |
The flow also provides methods such as close() and on().
Returns
Behaviour
The handle resolves when the flow has mounted, rather than when a purchase completes.