Skip to main content
Events provide a way to receive updates on the status of swaps and handle errors through custom callbacks. You do not need to import anything extra to make use of event callbacks, instead simply add them using the events field inside the settings prop on LayerswapProvider.
<LayerswapProvider
    callbacks={{
      // events callbacks go here
    }}
>
  ...
</LayerswapProvider>
onFormChange: Called whenever the swap form values change — for example, when the user updates the asset, amount, or destination network. onSwapCreate: Called when a new swap is successfully created after submitting the form. onSwapComplete: Called when a swap completes successfully on-chain or via an integrated exchange. onSwapModalStateChange: Called when the swap modal is opened or closed. onBackClick: Called when the user clicks the back button in the swap flow.