@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
config—apiKey,version,theme,initialValueskeep working as-is.callbacks— the same eight callback names and payloads remain available, includingonSwapStatusChangeandonMenuNavigationChange.
- The CSS import (
@layerswap/widget/index.css) — styles inject at runtime. - The
walletProvidersarray and allcreate*Provider()factories.
3. Map your wallet provider setup
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:
transpilePackagesentries for@layerswap/*innext.config.ts- webpack
resolve.fallback/externalstweaks forfs,net,tls,pino-pretty, etc. vite-plugin-node-polyfills,stream-browserify,Buffer/processglobalsssr.noExternal/optimizeDeps.includelists for@layerswap/*next/dynamicwrappers withssr: false— the component is SSR-safe by itself
5. Migrate the Deposit Widget
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, andwalletProvidersConfigto module scope or memoize them to avoid provider rebuilds and extra renders. - Loader-level props are new:
fallback(loading state),onReady, andonErrorfor load failures — distinct fromcallbacks.onError. - If you serve a CSP, allowlist the widget CDN origin — see the recommended CSP.