> ## Documentation Index
> Fetch the complete documentation index at: https://docs.li.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# Widget Integration

> Composer works automatically in the LI.FI Widget. Configure a deposit widget and detect Composer routes in execution events.

Composer routes are available automatically when the LI.FI Widget targets a supported position token; no Composer-specific configuration is required. When a user picks a vault token as the destination, the routing engine compares Composer routes with DEX and bridge routes into that token. A same-chain route runs in one transaction; a cross-chain route runs in one, or two if it has a separate destination-chain step.

To add the Widget to your app, see [Install Widget](https://docs.li.fi/widget/install-widget.md). For wallet connections, see [Wallet Management](https://docs.li.fi/widget/wallet-management.md).

***

## Build a deposit widget

Pre-select the vault token as the destination and lock it, so users only choose the source token and amount:

```tsx theme={"system"}
import type { WidgetConfig } from "@lifi/widget";

const widgetConfig: WidgetConfig = {
  integrator: "YourAppName",
  toChain: 8453, // Base
  toToken: "0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A", // Morpho vault token
  disabledUI: { toToken: true, toAddress: true },
  chains: {
    from: { allow: [1, 10, 42161, 8453] }, // Ethereum, Optimism, Arbitrum, Base
  },
};
```

Omit `disabledUI` to pre-fill the destination without locking it. `chains.from.allow` restricts the source chains; `chains.allow` (without `from` or `to`) restricts both lists. See [Configure Widget](https://docs.li.fi/widget/configure-widget.md) for all chain and token filters and [Customize Widget](https://docs.li.fi/widget/customize-widget.md) for every `disabledUI` field, layout variants and theming.

***

## Detect Composer routes in events

The `useWidgetEvents` hook emits execution events. A route uses Composer when one of its steps has an `includedSteps` entry with `tool: "composer"`. Subscribe outside the component that renders `LiFiWidget` to avoid re-renders:

```tsx theme={"system"}
import type { Route } from "@lifi/sdk";
import {
  useWidgetEvents,
  WidgetEvent,
  type RouteExecutionUpdate,
} from "@lifi/widget";
import { useEffect } from "react";

const usesComposer = (route: Route) =>
  route.steps.some((step) =>
    step.includedSteps.some((included) => included.tool === "composer"),
  );

export function ComposerEvents() {
  const widgetEvents = useWidgetEvents();

  useEffect(() => {
    const onStarted = (route: Route) => {
      console.log("Execution started. Composer route:", usesComposer(route));
    };
    const onUpdated = (update: RouteExecutionUpdate) => {
      console.log("Execution updated:", update.action.type, update.action.status);
    };
    const onCompleted = (route: Route) => {
      console.log("Execution completed:", route.id);
      // e.g., refresh the user's vault position in your UI
    };
    const onFailed = (update: RouteExecutionUpdate) => {
      console.error("Execution failed:", update.action.error?.message);
    };

    widgetEvents.on(WidgetEvent.RouteExecutionStarted, onStarted);
    widgetEvents.on(WidgetEvent.RouteExecutionUpdated, onUpdated);
    widgetEvents.on(WidgetEvent.RouteExecutionCompleted, onCompleted);
    widgetEvents.on(WidgetEvent.RouteExecutionFailed, onFailed);

    return () => {
      widgetEvents.off(WidgetEvent.RouteExecutionStarted, onStarted);
      widgetEvents.off(WidgetEvent.RouteExecutionUpdated, onUpdated);
      widgetEvents.off(WidgetEvent.RouteExecutionCompleted, onCompleted);
      widgetEvents.off(WidgetEvent.RouteExecutionFailed, onFailed);
    };
  }, [widgetEvents]);

  return null;
}
```

For every event, see [Widget Events](https://docs.li.fi/widget/widget-events.md).

***

## Try it live

> [card] [Widget Playground](https://playground.li.fi/)
>
> Test Composer flows in the LI.FI Widget


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.