- 允许或拒绝特定的链、代币、桥接器和交易所。
- 预设默认的源链和目标链。
- 为源链和目标链选择默认代币。
- 设置目标代币的数量。
- 指定目标地址。
-
通过
sdkConfig
配置自定义各种 LI.FI SDK 设置。
LI.FI SDK 配置
LI.FI 组件构建在 LI.FI SDK 之上,利用其强大的跨链交换和桥接功能。sdkConfig 选项允许您直接在组件中配置 SDK 的各个方面。 让我们看看使用 sdkConfig 选项配置私有 RPC 端点的示例。In a production app, it is recommended to pass through your authenticated RPC provider URL (Alchemy, Infura, Ankr, etc).If no RPC URLs are provided, LI.FI Widget will default to public RPC providers.Public RPC endpoints (especially Solana) can sometimes rate-limit users depending on location or during periods of heavy load, leading to issues such as incorrectly displaying balances or errors with transaction simulation.
Initialize form values
The LI.FI Widget uses a number of form values that are used to fetch and execute routes. These values arefromAmount
, fromChain
, fromToken
, toChain
, toToken
and toAddress
.
They are most often set by using the Widget UI but they can also be initialized and updated programmatically.
By configuring these options, you can streamline the user experience, ensuring that the widget is preloaded with the desired chains, tokens, amount and address for a swap or bridge. This reduces the need for manual input and helps guide users through the intended flow.
You can initialize these values by either:
-
Widget config - by adding
fromAmount
,fromChain
,fromToken
,toChain
,toToken
ortoAddress
values to the widget config. -
URL search params - when
buildUrl
中 widget config is set totrue
, by adding them to the URL search params 中 url of the page the widget is featured on.
Initializing by widget config
The LI.FI Widget allows you to preconfigure default chains and tokens, making it easy to set up your desired swap or bridging parameters right from the start. Below is an example of how to configure the widget with specific default chains, tokens, amount, and send to address values.minFromAmountUSD
parameter (number) to ensure users meet minimum transaction requirements.
Initializing by URL search params
To initialize form values 中 widget using URL search params you will need to ensure thatbuildUrl
is set to true
中 widget config.
Config values override URL search paramsIf you want to use URL search params to populate the widget’s form values on initialization (or page load) its important that those form values are NOT featured 中 config object used to initialize the widget. fromAmount, fromChain, fromToken, toAddress, toChain, and toToken should NOT be set on the widget config in order to allow the URL to perform the initial set up of the widgets state.On first page load if you have form values in both the config and the URL then the URL search params will be rewritten to match the config values and the widget form will be populated with the values presented 中 config.
Update form values
After the widget has initialized there are two ways you can update the form values 中 widget- Using the widget config - this uses reactive values 中 config and requires some management of those values for updates
- Using the formRef - this provides an function call that you can use to update values 中 widgets form store.
Note that when
buildUrl
is set to true
中 widget config both methods
should also update the URL search params as well as the value displayed 中
widget itself.Updating by widget config
Once the widget has initialized you can update the form values 中 widget by updating the widget config. To perform an update you should only include the form values 中 config that you want to change and ensure these changes are passed to the Widget. For example, if you want to change the fromChain and fromToken and nothing else you should include only include those values In addition to the form values you want to change you should also set a formUpdateKey. This needs to be a unique, randomly generated string and is used to ensure that the form values are updated 中 widget - essentially forcing an update. This can avoid some edge case issues that might arise when setting values 中 widget via a mix of config and user actions via the widgets UI. Here is an example of what your config would look like.undefined
. This example resets only the fromChain and fromToken form values.
undefined
used to reset a the widgets form value to an empty state. The absence of a property from the widget config object means that property will remain unchanged.
State management with widget config
When using config to update widgets form values it is often a good choice to consider using an application state management library to store your widget config. There are many options to choose from such as Zustand, MobX, Redux or even React context.
For example, if you were to use Zustand as your state management tool you could use Zustand’s API to access and set values on your config from any part of your application. In addition you would also be able to use Zustand’s equality functionality, such as the built-in shallow
function, to ensure that your widget config is only used to update the instance of the LiFi Widget when necessary. This should be beneficial for optimizing re-renders.
You can find an example that uses Zustand to manage widget config 中 widget repository.
Updating by form ref
This method provides developers a way to set the form values directly 中 widget without making changes to the widget config. By passing a ref object to the widget you can access a function to set values directly on the widgets form state. See the example below.setFieldValue
function.
setFieldValue
function can be called to set the form value, note that setUrlSearchParam
will ensure the url is updated if you have buildUrl
set to true
in your widget config.
Here are some examples of usage.
Configure allow and deny options
We provideallow
and deny
configuration options to control which chains, tokens, bridges, and exchanges can be used within your application. Here’s how you can set up and use these options:
allow
and deny
options:
- If defined at the top level of the
tokens
object, they apply to both lists. - If defined inside the
from
orto
objects, they apply only to that specific list. - If an
allow
list is defined, only tokens included in it are allowed. If noallow
list is defined, all tokens are allowed unless they are explicitly included indeny
. If a token appears in bothallow
anddeny
, theallow
list takes precedence. - A token must pass both the top level
allow
/deny
check and the check for the current list (from
orto
) to be considered allowed. - Token filters are applied per chain. When tokens are allowed/denied for a specific chain, only that chain’s tokens are affected. Other chains remain unfiltered and show all their available tokens.
allow
and deny
options, the tokens
option can be configured to include other tokens or featured tokens that will appear at the top of the corresponding list of tokens.

With featured tokens

Without featured tokens
Destination address
There are use cases where users need to have a different destination address. Usually, they can enter the destination address independently. Still, the widget also has configuration options to pre-configure the destination address or create a curated list of wallet addresses to choose from.
Send to wallet button

Send to wallet view
Configure single destination address
Developers can use thetoAddress
option to configure a single destination address. The address
and chainType
properties are required, while the name
and logoURI
properties are optional.

Configure a curated list of wallet addresses
Developers can usetoAddresses
option to configure a curated list of wallet addresses.
Send to wallet
button, they will open a pre-configured list of addresses from which to choose, skipping the step where they can manually enter the address.
Together with configuring the wallet list, developers can make the destination address required to be filled out. Please see Required destination address for more details.

Optional destination address

A curated list of wallet addresses
Explorer URLs
In the widget there are numerous points where a user can click to open an explorer in a separate browser tab in order to find out more information about a transaction or an address. Any buttons or links 中 widget that present this icon will direct the user to an explorer. We have default behaviors in relation to opening explorers and we can also use widget config to override and change these behaviors.Default behavior for chains
Often when trying to direct a user to an explorer the widget will know which chain relates to a transaction or address and it will present an explorer that matches that chain. For example, after the user has executed a transaction, on the transaction details page they can click on the “Token allowance approved” explorer button to see more detail about that approval. If the approval was done using the Optimism cha中n a new tab would open taking the user to optimistic.etherscan.io to show them more information about that approval. If no explorer can be found in relation to a cha中n the user will be directed to LiFi’s explorer.Default behavior for internal explorers
An internal explorer is an explorer that is the preferred choice of an organization that is building an app using the widget. In some parts of the widget we use an internal explorer rather than attempting to find an explorer for a specific chain. For example, once the user has completed a transaction and is on the transaction details page they are presented with a transfer ID (see below). This is accompanied by a link which allows the user to open an explorer in order to find more information about that transaction. There is no attempt to find a chain specific explorer. The default explorer used is LI.FI own internal explorer and users will be directed to https://scan.li.fiOverriding the explorer URLs
It’s possible to override the explorer URLs that widget uses via the widget config. We can do this for specific chains and for the internal explorer. You can use your own explorer urls for multiple chains and at the same time state your own alternative for the internal explorer.Overriding explorers for a chain
In the widget config you can override chains by adding an entry to the explorerUrls object: you provide the chain id as a key and the base url of the explorer as the value.Overriding explorers for the internal explorer
In the widget config you can override the internal explorer by adding an entry to the explorerUrls object: you provideinternal
as a key and the base url of the explorer as the value.
Address and transaction pages
The widget assumes that the explorer will provide pages for addresses at/address/:address
and for transactions at /tx/:hash
and will attempt to navigate the user to those pages when the users clicks the related buttons.
A link to a wallet address would look like:
Adding route labels
The Widget allows you to visually enhance specific routes by adding route labels — styled badges with customizable text and appearance. To display route labels dynamically, configure therouteLabels: RouteLabelRule[]
array in your WidgetConfig
.
text
and sx
styling of the badge 中 MUI-style CSS-in-JS way.
The rest of the fields determine when and where a label should be applied based on route conditions.
You can combine multiple criteria such as fromChainId
, exchanges
, tokens
, and more.
For bridges and exchanges, use the allow
and deny
fields for fine-grained control, similarly to how it is described in Configure allow and deny options.
Example configuration:

Route labels example