---
updatedAt: 2026-09-02T01:50:27.000Z
agentTools:
  projectIndex: https://docs.zeptopayments.com/llms.txt
---

# Mount the Widget

Add the Flow widget to your checkout page and start the payment session.

<div class="zepto-docs-hero">
  <div class="zepto-docs-hero__content">
    <span class="zepto-docs-hero__badge">DEVELOPER GUIDE</span>
    <h1>Mount the Widget</h1>
    <p>Add the Flow widget to your checkout page and start the payment session.</p>
  </div>
  <div class="zepto-docs-hero__visual" aria-hidden="true">
    <div class="zepto-docs-hero__glow"></div>
    <div class="zepto-docs-hero__icon">
      <img class="logo" alt="Zepto Flow" src="https://files.readme.io/dcc5db35e266b31d34fe90b3c87705e876f39854b29984127983f42e647d2187-Integration.png">
    </div>
  </div>
</div>

After you create a Payment Intent, you can render Flow on your checkout page. Load the SDK, give it a mount target, and start the session with the `{ token, action }` from your backend.

## Add the SDK and a mount target

```html
<script src="https://go.sandbox.zeptopayments.com/flow/assets/flow.js"></script>
<div id="zepto-flow"></div>
```

The `<div>` is where the widget renders. Size and position it as you would any element on your page. This example loads the **sandbox** bundle. When you go live, load `https://go.zeptopayments.com/flow/assets/flow.js` instead.

## Mount the widget

Fetch the `{ token, action }` from your backend and pass it to `ZeptoFlow.mount()`:

```html
<script>
  // { token, action } from your create-payment-intent response
  const { token, action } = await fetch('/api/payment-intent', {
    method: 'POST',
  }).then((r) => r.json());

  const widget = ZeptoFlow.mount('#zepto-flow', { token, action });

  widget.subscribe((event) => {
    if (event.type === 'zepto:payto:payment-settled') {
      window.location.assign('/checkout/success');
    }
    if (event.type === 'zepto:payto:payment-failed') {
      showRetry(event.payload.errors);
    }
  });
</script>
```

That is the whole client integration. `mount()` renders the widget and starts the workflow. `subscribe()` lets your page react as the workflow progresses.

## The mount handle

`ZeptoFlow.mount(target, options)` returns a handle you can use to control the widget:

| Method                | Purpose                                                                                                           |
| --------------------- | ----------------------------------------------------------------------------------------------------------------- |
| `element`             | The element the widget rendered into.                                                                             |
| `update(partial)`     | Patch mounted options. A fresh `{ token, action }` restarts the widget for a new Payment Intent on the same host. |
| `subscribe(listener)` | Register a lifecycle-event listener. Returns an unsubscribe function.                                             |
| `destroy()`           | Unmount the widget and abort any in-flight request.                                                               |

See the **[SDK reference](https://docs.zeptopayments.com/docs/zepto-flow-sdk-reference)** for full signatures, mount options, and theming.

<Zepto_Callout type="info" title="The target accepts a selector or an element" id="target-accepts-a-selector">
Pass a CSS selector string (like `'#zepto-flow'`) or a DOM `Element`. `mount()` throws immediately if the selector matches nothing.
</Zepto_Callout>

## Next steps

Learn how to **[handle the payment lifecycle](https://docs.zeptopayments.com/docs/zepto-flow-payment-lifecycle)**: the events the widget emits and what each one means.