Skip to main content
@layerswap/widget-react replaces the self-bundled @layerswap/widget integration. The widget’s code moves out of your bundle and onto Layerswap’s signed CDN; your app keeps only a thin loader. The migration is mostly deleting things.

1. Swap the packages

react and react-dom (18 or 19) are the only required peers. Keep wagmi only if you pass a wagmiConfig (it’s a types-only peer for the widget).

2. Replace the provider tree with one component

What carries over unchanged:
  • configapiKey, version, theme, initialValues keep working as-is.
  • callbacks — the same eight callback names and payloads remain available, including onSwapStatusChange and onMenuNavigationChange.
What’s removed:
  • The CSS import (@layerswap/widget/index.css) — styles inject at runtime.
  • The walletProviders array and all create*Provider() factories.

3. Map your wallet provider setup

Add the official support channel for custom-provider migration questions.
The Solana provider id is 'solana', not 'svm' (the legacy package name was @layerswap/wallet-svm).

4. Delete your bundler workarounds

All of the following are unnecessary with @layerswap/widget-react and can be removed:
  • transpilePackages entries for @layerswap/* in next.config.ts
  • webpack resolve.fallback / externals tweaks for fs, net, tls, pino-pretty, etc.
  • vite-plugin-node-polyfills, stream-browserify, Buffer/process globals
  • ssr.noExternal / optimizeDeps.include lists for @layerswap/*
  • next/dynamic wrappers with ssr: false — the component is SSR-safe by itself

5. Migrate the Deposit Widget

The deposit-specific props (destination, destinationAddress, mode, methods, …) are unchanged — see the Deposit Widget reference. For a deposit-address-only setup (previously “omit walletProviders”), pass methods={['deposit_address']}.

6. Review the behavioral differences

  • Widget updates roll forward automatically on the CDN channel—you no longer pin the remote implementation through npm. Verify the final 2.x release-channel policy on release day. See Widget delivery and security.
  • One widget per page (of either kind) — the widget keeps process-global state.
  • Object props are compared by reference—hoist config, callbacks, walletDefaults, and walletProvidersConfig to module scope or memoize them to avoid provider rebuilds and extra renders.
  • Loader-level props are new: fallback (loading state), onReady, and onError for load failures — distinct from callbacks.onError.
  • If you serve a CSP, allowlist the widget CDN origin — see the recommended CSP.