- One iframe, nothing to run. No
@sodax/*package, no backend, no liquidity to bootstrap. New networks and assets appear without a release on your side. - Your fee. Set it from 0 to 1% in the dev portal, behind your app ID.
- Real swaps. Mainnet only, with no test mode. That includes the preview in the builder.
Quickstart
1
Create your app ID
Sign in to the SODAX dev portal
for free, open Swap widget, set your fee and the Sonic address that receives it, and save.
That creates your app ID.
2
Build your widget
Open the builder, paste the ID into Setup, and set your pair,
restrictions and branding.
3
Embed it
Copy the HTML or React code from Integrate and paste it into your page.
How it works
Your app ID- Required: without it, the widget does not quote or swap.
- It holds your fee and its receiving address, so nobody can change them by editing the embed.
- It is public and never changes, so it is safe in your page’s source.
- It covers widget swaps only, not swaps you make through the SDK or API.
- Fees build up on Sonic until you claim them.
- Quotes, network and token lists, wallet connection, balances and approvals.
- Signing, settlement tracking and recovery after a page reload.
- Receiving-account setup that some networks require.
- The
<iframe>with itsallowattribute, in a slot at least 760px tall. - A
frame-srcentry, if you send a Content Security Policy. - Optionally, a
messagelistener for height and swap status.
- Users connect their wallet inside the widget, not through your app. The React snippet wraps the
same iframe. To swap on your own wallet connection, use
@sodax/dapp-kitinstead. - Quotes show before a wallet is connected.
What the widget can execute
- Swap in the widget: EVM, Solana, Sui, Stellar, NEAR, Stacks and Injective. Both sides of the route must be on this list.
- Quote only: every other network the swaps API lists. Users see the quote, then Continue on SODAX opens the SODAX exchange, where they select the trade again. The builder and token picker label these networks Quote only.
- Bitcoin never signs in the widget: it settles through a funded trading wallet.
Configure it in the builder
The preview beside the panels is the real widget. It works before you add an app ID, without your fee, and swaps in it use real funds.- Setup: your app ID, the starting pair, amount and slippage, and which networks and tokens each side allows. Lock a side to fix its token and network, for example for a deposit-only widget.
- Appearance: a preset, or your own theme, colours, font, radius and density. Text that would be hard to read is adjusted for contrast.
- Integrate: your code as HTML, React or a prompt for your coding agent, once your app ID is in.
The SDK tab shows the same quote with
@sodax/dapp-kit.
Embed it
The whole embed is one<iframe>:
- Keep the
allowattribute. Brave shows wallets to a third-party frame only when the host page allows it. Other browsers ignore it. - No wallet in the frame? The widget always offers users Open in a new tab.
- Content Security Policy? Add the widget to
frame-src:
Configuration parameters
The builder writes these into thesrc for you. Unknown values are ignored.
- Locks need
embed=1and the pair they pin. Without the pair, that side lists no assets. - Restrictions shape this UI, not access to the public API. One that matches no listed asset blocks the route rather than swapping in another token, even when a locked token is only temporarily unavailable.
- Hand-writing a URL? Set
themewithsurface, or the first paint can flip themes.
Swap lifecycle messages
- The widget posts only to your page’s origin, never
*. Checkevent.originandevent.sourcein your listener, as the one from Integrate does. - Messages carry a status and nothing else: no addresses, amounts or hashes.
To follow your site’s theme, send
{ type: 'sodax:theme', theme: 'light' | 'dark' | 'auto' } after
sodax:ready.
Troubleshooting
Next steps
Swap overview
How swaps work, and the other ways to integrate them.
HTTP API
Your own swap UI, in any language.
React hooks
@sodax/dapp-kit, for swaps on your own wallet connection.Widget reference
The full lifecycle and analytics events, in the repo.