Skip to main content
@layerswap/widget-js is the framework-agnostic loader behind @layerswap/widget-react. Use it from Vue, Angular, Svelte, or any environment with a DOM.
@layerswap/widget-js is an npm ESM package, not a <script> tag — there is no UMD build. The widget is fetched from Layerswap’s CDN at runtime, but the loader is installed from npm and imported by your bundler. The delivery and verification pipeline is identical to the React package — see Widget delivery and security.

Install

The host app does not need React — the remote bundles its own React and owns its own React root.

Mount the widget

mountWidget(target, props) fetches the widget from the CDN (with manifest signature verification) and mounts it into target. It returns a promise of a handle:
(props) => void
Re-render the mounted widget with new props.
() => void
Unmount the widget and release its React root. Call it when the host view is torn down (e.g. in your framework’s unmount hook).
mountWidget throws if called server-side (window is required) or with a falsy target.

Deposit Widget release check

mountDepositWidget is planned to take the common props plus the deposit-specific ones:
In the JavaScript package, a second mount throws synchronously. Mixing the React and JavaScript loaders can also fail during remote initialization because they use different share configurations.

Props

The props object is the same contract as the React package — config, callbacks, walletDefaults, walletProvidersConfig — so the Configuration, Wallets, Customization, and Event Callbacks pages all apply, with two exceptions:
  • No wagmiConfig — sharing a host wagmi config is a React-host feature.
  • No React nodesconfig.loadingComponent and the React fallback prop don’t exist here (attempting to pass them is a compile-time error in TypeScript). Show your own loading state until the mountWidget promise resolves.

Framework example (Vue)