> ## 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.

# Methods

> Signatures and verified behavior for Connect.js 2.2.0 methods.

Connect.js exposes five public methods for mounting, opening, closing, and querying the widget integration.

## `setup(config?)`

Mounts the widget in the document and keeps it hidden until `open()` runs.

```javascript theme={null}
connect.setup()
```

Pass optional institution and account-match configuration to start further into an account-linking flow.

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

| Field                                | Type    | Description                                      |
| ------------------------------------ | ------- | ------------------------------------------------ |
| `selectedInstitution.id`             | string  | Institution to load.                             |
| `selectedInstitution.auth_method`    | string  | Authentication method to preselect.              |
| `selectedInstitution.account_number` | string  | Account number used by account-match flows.      |
| `check_account_match`                | boolean | Requests account-number matching when supported. |

## `reauthorise(accountId)`

Mounts the reauthorization widget for an existing linked account. The widget remains hidden until `open()` runs.

```javascript theme={null}
connect.reauthorise("account_xyz")
```

| Parameter   | Type   | Required | Description                                         |
| ----------- | ------ | -------- | --------------------------------------------------- |
| `accountId` | string | Yes      | Mono account ID for the account being reauthorized. |

The method throws when the account ID is missing or is not a string. Use `reauthorise()` in place of `setup()` for a reauthorization instance.

## `open()`

Shows the widget mounted by `setup()` or `reauthorise()` and starts the window-message listener used for callbacks.

```javascript theme={null}
connect.setup()
connect.open()
```

Call `open()` from an explicit user action such as a button click.

## `close()`

Hides the widget, removes the active window-message listener, and invokes the configured `onClose` callback.

```javascript theme={null}
connect.close()
```

The SDK also closes the widget after a successful account-linking or charge-complete message.

## `fetchInstitutions()`

Requests institution coverage from `https://api.withmono.com/coverage` through Axios.

```javascript theme={null}
const response = await connect.fetchInstitutions()
console.log(response.data)
```

The method returns the Axios promise rather than only its `data` property. Handle network and non-success responses.

```javascript theme={null}
try {
  const { data } = await connect.fetchInstitutions()
  renderInstitutions(data)
} catch (error) {
  showCoverageError(error)
}
```

## Complete lifecycle

```javascript theme={null}
import Connect from "@mono.co/connect.js"

const connect = new Connect({
  key: "PUBLIC_KEY",
  scope: "auth",
  data: { customer: { id: "CUSTOMER_ID" } },
  onSuccess: ({ code }) => sendCodeToBackend(code),
  onClose: () => console.log("Connect closed")
})

connect.setup()

document
  .querySelector("#link-account")
  .addEventListener("click", () => connect.open())
```
