> ## Documentation Index
> Fetch the complete documentation index at: https://sammydocs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Parameters

> Constructor, customer, payment, and setup parameters for Connect.js 2.2.0.

Pass constructor parameters to `new Connect(options)`. The SDK requires `key` and `onSuccess`; other values configure callbacks or are forwarded to the hosted widget.

## Constructor parameters

| Parameter   | Type     | Required       | Purpose                                                    |
| ----------- | -------- | -------------- | ---------------------------------------------------------- |
| `key`       | string   | Yes            | Mono public application key.                               |
| `onSuccess` | function | Yes            | Receives the flow-specific success result.                 |
| `scope`     | string   | Flow-dependent | Use `auth` for linking or `payments` for payment examples. |
| `data`      | object   | Flow-dependent | Customer or payment configuration.                         |
| `onClose`   | function | No             | Runs when the widget closes.                               |
| `onLoad`    | function | No             | Runs after the widget iframe loads.                        |
| `onEvent`   | function | No             | Receives `eventName` and event-specific `data`.            |
| `reference` | string   | No             | Correlation value included in supported event payloads.    |

## Account-linking configuration

```javascript theme={null}
const connect = new Connect({
  key: "PUBLIC_KEY",
  scope: "auth",
  data: {
    customer: {
      id: "CUSTOMER_ID"
    }
  },
  reference: "APPLICATION_CORRELATION_ID",
  onSuccess: ({ code }) => sendCodeToBackend(code),
  onClose: () => console.log("Connect closed"),
  onLoad: () => console.log("Connect loaded"),
  onEvent: (eventName, data) => console.log(eventName, data)
})
```

### Customer

Identify an existing Mono customer with its ID:

```javascript theme={null}
data: {
  customer: { id: "CUSTOMER_ID" }
}
```

Or supply fields for a new customer:

```javascript theme={null}
data: {
  customer: {
    name: "Ada Lovelace",
    email: "ada@example.com",
    identity: {
      type: "bvn",
      number: "CUSTOMER_BVN"
    }
  }
}
```

Check official Mono documentation for current customer and identity requirements before production use.

## Payment configuration

Current package examples pass payment configuration inside `data`.

```javascript theme={null}
const connect = new Connect({
  key: "PUBLIC_KEY",
  scope: "payments",
  data: {
    type: "one-time-debit",
    amount: 150000,
    description: "Electricity bill"
  },
  onSuccess: (charge) => verifyChargeOnBackend(charge)
})
```

| Field              | Example            | Meaning                                             |
| ------------------ | ------------------ | --------------------------------------------------- |
| `data.type`        | `one-time-debit`   | Payment flow type used by current package examples. |
| `data.amount`      | `150000`           | Integer amount in the currency's minor unit.        |
| `data.description` | `Electricity bill` | User-visible payment description.                   |

Confirm current allowed types and required fields in Mono's official payment documentation.

## Setup configuration

Pass setup-only values to `setup(config)` rather than the constructor.

```javascript theme={null}
connect.setup({
  selectedInstitution: {
    id: "INSTITUTION_ID",
    auth_method: "internet_banking",
    account_number: "ACCOUNT_NUMBER"
  },
  check_account_match: true
})
```

## Secrets

The constructor accepts a public key. It does not require the Mono secret key.

<Warning>
  Keep `MONO_SECRET_KEY` on your backend. Never pass it to `new Connect()`, expose it through a browser environment variable, or include it in frontend logs.
</Warning>
