> For the complete documentation index, see [llms.txt](https://docs.intents.aurora.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.intents.aurora.dev/intents-swap/widget-configuration/widgets.md).

# Widgets

The **Intents Swap Widget** package exports multiple pre-built widget components, `Widget`, `WidgetSwap`, `WidgetWithdraw` and `WidgetDeposit`.

The `Widget` component is the one you will want to use in most cases. The others being used when you want to build more specific UIs.

By default `Swap` mode is active when widget is rendered. You can change this by passing the `defaultMode` property to the `Widget` component.

### Usage

In their most basic form, all of these components can be rendered with no additional properties, for example:

```tsx
import { Widget } from '@aurora-is-near/intents-swap-widget';

<Widget />
```

As well as the global configuration properties provided via the `WidgetConfigProvider` (see Configuration), the widgets each accept a number of properties.

### Making transfers

The package will make EVM and Solana transfers by default. If you want to implement your own custom transfer logic you can pass in a `makeTransfer` function as widget property.

The function is called with an object that contains details about the transaction, which is typed like this:

```ts
export type MakeTransferArgs = {
  amount: string;
  decimals: number;
  address: string;
  tokenAddress?: string;
  chain: Chains;
  evmChainId: number | null;
  isNativeEvmTokenTransfer: boolean;
  sourceAssetId: string;
  targetAssetId: string;
};
```

Your `makeTransfer` function should return the transaction `hash` and a `transactionLink`, which are used when displaying the transfer success screen.

#### Example

```tsx
  <Widget
    makeTransfer={(args) => {
      const hash = performTonSwap(args);

      return {
        hash: hash,
        transactionLink: `https://tonviewer.com/transaction/${hash}`,
      }
    }}
  />
```

The `makeTransfer` function is called with a second argument that defines the widget type. This can be useful if you have enabled account abstraction and need to modify the transfer behaviour in some way, or log analytics events, based on the widget type (i.e. swap, deposit or withdraw).

### Listen to events

Each `Widget` component exposes `onMsg` prop that allows you to listen to some events in the transfer pipeline. E.g. widget deposit mode component has the following events exposed that can be used like:

```tsx
<Widget onMsg={msg => {
    switch (msg.type) {
        case 'on_select_token':
        case 'on_change_deposit_type':
        case 'on_tokens_modal_toggled':
            break
        case 'on_transfer_success':
            // you can access event's data here e.g. transaction hash
            console.log(msg.hash)
            break;
        default:
            break;
    }
}} />
```

For events of other widget types please refer to their `Props` type.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.intents.aurora.dev/intents-swap/widget-configuration/widgets.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
