client.connect() when you need to connect a customer’s MoonPay account in your app. This method mounts the co-branded connect flow into your UI and streams lifecycle events through onEvent.
If you want the full end-to-end flow (create session → check connection → connect), start with the Connect a customer guide.
For UI recommendations, see Presentation and appearance.
Connect a customer
The promise returned by
client.connect() resolves after the customer
completes the connect flow (or an error ends it). Track flow progress —
including the moment the UI is ready to show — through onEvent, not by
awaiting the promise.Parameters
ConnectEvent
onEvent receives events as the connect flow progresses. Use event.kind to decide how to handle each event.
To remove the frame from the DOM after the flow completes, call
connectFrame.dispose() on the ConnectFrame returned from client.connect(). The frame handle only becomes available once the flow completes — the returned promise stays pending while the customer works through the flow.
ConnectEventError
The error event payload comes from the underlying connect frame. It is discriminated by code.
ConfigValidationFieldError entries have a code of "invalidSessionToken", "invalidClientToken", or "invalidPublicKey", plus a developer-facing message.
types.ts
Result
client.connect() returns a Result<ConnectFrame, ConnectError>.
Result envelope
Result<ConnectFrame, ConnectError>
ConnectFrame
ConnectError
ConnectError covers failures to mount the frame or complete the handshake. Per-flow failures inside the frame surface through the "error" event payload, ConnectEventError.
types.ts