# loadAntom()

> loadAntom() is the entry function for loading an Antom SDK instance. By accepting configuration parameters, it asynchronously loads and returns the Antom instance, which is used for subsequent operations such as creating Elements, updating configuration parameters, initiating payments, or binding payment methods.

`loadAntom()` is the entry function for loading an Antom SDK instance. By accepting configuration parameters, it asynchronously loads and returns the Antom instance, which is used for subsequent operations such as creating Elements, updating configuration parameters, initiating payments, or binding payment methods.

> **Note**:
>
> -   The SDK uses a singleton pattern internally. Multiple calls to `loadAntom()` will return the same instance.
> -   `loadAntom()` is an asynchronous function. You must use `await` or `.then()` to retrieve the instance.
> -   When using the npm package, if script loading fails due to network issues, the method will return _reject_. It is recommended to check your network connection and refresh the page, or directly visit the corresponding CDN link to verify if the resource is accessible.

## **Method signature**

When calling this method, please use the following standard method signature format:

#### Tab: JavaScript

```javascript
loadAntom(config)
```

#### Tab: TypeScript

```typescript
loadAntom(config: LoadAntomConfig): Promise<antom>
```

## **Parameters**

This method accepts a configuration object that is used to initialize the SDK’s runtime environment and core behavior.

| **Parameter** | **Type** | **Required** | **Description** |
| --- | --- | --- | --- |
| [_config_](#Y3rHZ) | Object | No | SDK configuration object, which is used to set the environment, language, and debugging mode. |

### _config_

| **Parameter** | **Type** | **Required** | **Description** |
| --- | --- | --- | --- |
| _env_ | String | No | Environment configuration options. Valid values are:<br/><br/>- `sandbox`: Sandbox environment for testing.<br/>- `prod`: Default value. Production environment for online services. |
| _environment_ | String | No | The alias for _env_. If both are set, the value of _env_ takes precedence. Valid values are:<br/><br/>- `sandbox`: Sandbox environment for testing.<br/>- `prod`: Default value. Production environment for online services.<br/><br/>> **Note**: The _env_ and _environment_ parameters serve the same function; it is recommended to use the _env_ parameter consistently. |
| _debug_ | Boolean | No | Used to enable debug mode. Enabling it will output detailed logs, making it easier for developers to troubleshoot issues. Valid values are:<br/><br/>- `true`: Enable debug mode.<br/>- `false`: Default value, disable debug mode. |
| _locale_ | String | No | Used to set the internal display language for the SDK (such as error messages and prompts). Valid values are:<br/><br/>- `en_US`: Default value. English<br/>- `pt_BR`: Portuguese (Brazil)<br/>- `pt_PT`: Portuguese<br/>- `es_ES`: Spanish<br/>- `ko_KR`: Korean<br/>- `zh_CN`: Simplified Chinese<br/>- `zh_HK`: Traditional Chinese<br/>- `ms_MY`: Malay<br/>- `in_ID`: Indonesian<br/>- `th_TH`: Thai<br/>- `vi_VN`: Vietnamese<br/>- `tl_PH`: Filipino<br/>- `it_IT`: Italian<br/>- `de_DE`: German<br/>- `fr_FR`: French<br/>- `nl_NL`: Dutch<br/>- `ja_JP`: Japanese<br/>- `ro`: Romanian<br/>- `pl_PL`: Polish<br/>- `ar_SA`: Arabic<br/>- `tr_TR`: Turkish<br/>- `hi_IN`: Hindi<br/><br/>> **Note**: If the parameter is omitted or contains an unsupported value, the system will default to English. |

## Return values

This method returns a `Promise` object, which resolves to an antom instance that provides the following main methods:

| **Function** | **Description** |
| --- | --- |
| [`antom.createElement()`](https://docs.antom.com/ac/sdks/web_antom-createElement.md) | Create Element instances, such as [CVVElement](https://docs.antom.com/ac/sdks/web_CVVElement.md), [VaultingElement](https://docs.antom.com/ac/sdks/web_VaultingElement.md), etc. |
| [`antom.confirmPayment()`](https://docs.antom.com/ac/sdks/web_antom-confirmPayment.md) | Initiate payment confirmation for saved card scenarios. |
| [`antom.confirmCardSetup()`](https://docs.antom.com/ac/sdks/web_antom-confirmCardSetup.md) | Confirm card information for card binding scenarios. |
| [`antom.updateConfig()`](https://docs.antom.com/ac/sdks/web_antom-updateConfig.md) | Update SDK configuration parameters. |
| [`antom.destroy()`](https://docs.antom.com/ac/sdks/web_antom-destroy.md) | Destroy the `antom` instance and free up all related resources. |

## Sample

### CDN

```javascript
const antom = await window.loadAntom();
```

When introducing SDK through CDN, it is recommended to add CDN link of the latest antom sdk in the page. If the project is Typescript used, @ alipay/ams-checkout/antom can be added to **compilerOptions.types** in the **tsconfig** to get typescript input prompt when writing code. The following is a sample configuration:

```json
{
  "compilerOptions": {
    "types": ["@alipay/ams-checkout/antom"]
  }
}
```

### npm

```javascript
import { loadAntom } from '@alipay/ams-checkout';
// Load the production environment SDK
const antom = await loadAntom();
```