Payments
Crypto Payments — Hosted checkout & API for 110+ coins White Label — Your brand on the entire payment flow Processing — Auto-convert, withdrawals & controls Payouts — Mass crypto payouts by API or file Platform — Marketplace payments & commissions
Swap Plugins Affiliate Pricing Blog Docs Contact
Language
Sign in
All articles

How to Embed a Crypto Swap Widget on Your Website

Embed a crypto swap widget with an iframe or SDK: setup steps, security checks, compliance questions and how to choose a widget that fits your site.

CryptoPayr Oct 24, 2026 14.00 min read
How to Embed a Crypto Swap Widget on Your Website

How to Embed a Crypto Swap Widget on Your Website

Watercolor frame around crypto swap article title

To embed a crypto swap widget, you paste an iframe (or load a small JavaScript snippet) into the page where you want the swap form to appear. The provider’s hosted interface then handles quotes, wallet connection and execution. The embed itself takes minutes. The decisions around it take longer: who holds the funds, how the iframe talks to your page, what you must disclose, and how the widget fits your design and your business model.

This guide walks through all of it, from the first line of HTML to the security headers you should set before going live.

Cryptopayr
Accept Crypto Payments on Your Website
CryptoPayr lets businesses accept over 110 cryptocurrencies, including Bitcoin and Ethereum, through a payment gateway for digital services.

TL;DR

Table of Contents

What a swap widget actually is

A crypto swap widget is an embeddable user interface that lets visitors exchange one cryptocurrency for another without leaving your site. According to the SwapKit documentation, such a widget is a drop-in, non-custodial swap interface that deals with wallets, quoting, approvals and execution, so the host site does not have to. Integration is typically a plain <iframe src="..."> tag or a JavaScript SDK that renders the component dynamically.

That description covers a wide family of products. They differ in ways that matter to you:

Pick the type first. A wallet-connect DEX widget suits a DeFi-literate audience. An instant exchange widget suits a general audience that holds coins on an exchange and just wants to move value.

Choosing a widget before you copy any code

Most of the pain people hit after embedding comes from a choice they skipped. Work through these criteria first.

Custody and who touches the funds

Ask where user funds sit at every step. In a non-custodial design, the widget never holds user keys. The security notes of one open-source embed SDK treat the iframe as an independent security principal that the host does not read from. The LI.FI guide takes a similar approach: the parent page owns the wallet connection and the widget relays requests through it.

If a provider takes deposits and sends out funds later, that is a different business model with different compliance duties. Neither is wrong, but you should know which one you are putting on your domain.

Coin and network coverage

A widget that supports ten coins is a feature. One that supports the coins your audience holds is a product. Check that stablecoins on the networks your users prefer are available, since the same stablecoin on different networks carries very different fees.

Account and onboarding friction

Every sign-up step costs conversions. Account-free flows are the fastest for the visitor, and they raise questions about compliance that we cover below. Our explainer on how no-KYC instant exchanges work lays out the mechanics.

Customization

Look for theme colors, default pairs, language, and the ability to preset a destination or a source asset. A widget that cannot match your typography will look like an ad, and visitors treat ads with suspicion when money is involved.

Monetization

Some providers share revenue on swaps made through your embed. The SwapKit documentation points out that this is not automatic: an affiliate or partner identifier has to be configured in the widget settings during initial setup. If you embed first and monetize later, you may be sending volume that earns you nothing.

How to embed a swap widget: step by step

The exact parameters differ by provider, so treat this as the pattern and read your provider’s documentation for the specifics.

  1. Get the embed code. Providers publish either an iframe snippet or an SDK package. Start with the iframe unless you need tight programmatic control.
  2. Create a dedicated container. Put the widget in its own section with a fixed minimum height, so the page does not jump when the frame loads.
  3. Paste the iframe. A typical snippet looks like this:
<iframe
  src="https://widget.example.com/swap?from=btc&to=usdt"
  title="Crypto swap"
  width="100%"
  height="640"
  style="border:0;max-width:480px"
  loading="lazy"
  referrerpolicy="strict-origin-when-cross-origin"
></iframe>
  1. Set the parameters. Default pair, theme, language and your partner ID, if the provider uses one.
  2. Restrict the frame. Add a sandbox attribute with only the permissions the widget needs. The MDN iframe reference warns that combining allow-scripts and allow-same-origin on a same-origin document lets it remove the sandbox, so do not grant both casually. Many third-party widgets need scripts to run at all, so test after you tighten.
  3. Test the full flow. Run a small swap end to end, on desktop and phone.
  4. Publish and monitor. Watch for console errors and for support questions that mention the widget.

The iframe versus the SDK

Iframe JavaScript SDK
Setup time Minutes Hours to days
Styling control Provider-defined options Often deeper
Isolation from your page Strong, by browser design Depends on implementation
Wallet handling Often inside the frame, or relayed by postMessage Handled in your app
Best for Content sites, landing pages, blogs Apps, dashboards, custom UX

For a marketing site or a blog, the iframe wins on speed and isolation. Reach for the SDK when the swap is a core product screen.

WordPress sites

If your site runs on WordPress, you can skip hand-written HTML. We publish a white-label exchange widget plugin for WordPress and a production-ready exchange theme. The first adds a swap form to any page. The second is for sites where the exchange is the whole point.

Security: treat the iframe as a trust boundary

An embedded widget runs code you did not write, next to pages your customers trust. Four habits cover most of the risk.

Validate message origins. If your page listens for postMessage events from the widget, check event.origin against the exact origin you expect. A write-up on cross-window communication misconfigurations shows how accepting messages from any source, or posting with a wildcard target, opens the door to cross-site scripting through a compromised third party.

const WIDGET_ORIGIN = new URL(iframe.src).origin;
window.addEventListener('message', (event) => {
  if (event.origin !== WIDGET_ORIGIN) return;
  // handle event.data
});

Deriving the origin from the iframe’s own source URL, as the LI.FI guide recommends, avoids typing it wrong and avoids wildcards.

Never pass keys. Wallet connection should be bridged by messages, with the host relaying signing requests. Private keys do not cross the frame boundary, ever. If a widget asks for a seed phrase, remove it.

Set frame-ancestors on your own pages. The same LI.FI guide advises a Content-Security-Policy with a frame-ancestors directive on the host to mitigate clickjacking. Note the direction: this controls who can frame your pages, which protects your logged-in areas, while the sandbox attribute and a frame-src rule control what you frame.

Limit what the frame can do. Use sandbox and a narrow allow list, and add the widget’s domain to your CSP frame-src so nothing else can load there.

Security boundaries for an embedded crypto swap widget

Keep a short change log too: when you update the embed, note the date, the provider version and who approved it. If something goes wrong, you will want to know what changed.

Compliance questions to settle first

This is the section people skip, so we put it before design.

A swap is a conversion between virtual assets. Businesses that facilitate exchange or transfer of virtual assets can fall under virtual asset service provider (VASP) rules. An AML guide to VASPs lists crypto-to-crypto exchange and transfers on behalf of a client among the covered activities, and notes that the FATF Travel Rule asks providers to collect and share originator and beneficiary data for qualifying transfers. As of mid-2025, that guide reports 73% of jurisdictions have enacted Travel Rule legislation, and enforcement timing still varies.

What that means for an embed depends on the setup:

We go deeper in our compliance playbook for crypto payments and in our piece on no-KYC swap APIs and noncustodial flows. Neither replaces legal advice, but both help you arrive at that conversation with the right questions.

Perspective: what we see when sites add swaps

We run a crypto payment gateway, and we also offer a KYC-free swap widget and API. That gives us a particular view of how people use embeds.

First, a swap widget works best where visitors already have a reason to hold or move crypto: a payments page, a wallet guide, a rates page, a gaming top-up flow. Dropping a swap form on an unrelated page gets looked at and ignored.

Second, the widget and the checkout should agree. A customer who lacks the right coin for your invoice should be able to convert in two clicks and come back. Merchants who treat swapping and accepting payments as separate projects tend to build the same friction twice.

Third, keep it simple. Choose a sensible default pair, state the fee and the estimated receive amount before anything is sent, and let people leave without an account. Most abandoned swaps we would expect to see come from surprises, not from technology.

Finally, be honest with your visitors about what you are. If you display someone else’s interface, say so in plain words near the widget and link to the terms of the service that runs it.

— Dustin

Design and conversion details that matter

Placement

Put the widget near the content that creates the need. On a guide about buying a product with Bitcoin, place it after the explanation, not above the headline. A sticky link in the nav to a dedicated swap page also works.

Size and responsiveness

Most swap forms are narrow, around 400 to 480 pixels. Center the frame, give it width:100% with a max width, and set a height that avoids an inner scrollbar on the confirmation step. Test on a small phone: the second screen of a swap flow is often taller than the first.

Defaults

Preselect the pair your audience is most likely to want. A gaming community may default to a stablecoin into the game’s accepted coin. A freelancer-focused site may default to the major coins into a stablecoin.

Performance

Use loading="lazy" for frames below the fold, and avoid loading several widgets on one page. Third-party frames can slow your largest contentful paint if they sit above the fold.

Trust cues

Show the fee, the rate source and the time estimate. Add a short note on what happens if a swap is delayed, and a support contact. People move money only when they can see a way out.

A swap widget is the fastest option, but it is not the only one. If you want a fully custom screen, an API gives you price quotes and swap creation under your own design. Our walkthrough of the six steps from price to signed swap shows the flow, and the Exchange API documentation covers public, no-account swaps.

If visitors only need to compare values, a crypto converter with live prices or a live rates page may be all your content needs. A common pattern: converter on the guide, swap widget one click away on the same page.

Our swap widget and gateway

If you want visitors to swap without an account, our instant crypto exchange works with no sign-up, and the widget and API let you bring that flow onto your own site. Teams that want their own branding can look at our white-label options, which are listed from 1% in fees.

Our swap widget and gateway — overview diagram

If you also sell something, pair the swap with checkout. Our gateway accepts 110+ cryptocurrencies, including Bitcoin and Ethereum, through hosted checkout, plugins, payment links and API, with no KYC for merchants. Processing fees are published on our site in tiers tied to monthly volume, from 2% on Standard down to 0.1% on Enterprise, and there is a flat 0.10 $ per-payment option on the gateway page. Online stores can start with crypto payments for e-commerce.

Pre-launch checklist

FAQ

Do I need a developer to embed a swap widget?

For a simple iframe, no. You paste a snippet into an HTML block or a page builder. A developer helps when you want origin checks, a CSP, custom events or an SDK integration inside an app.

Is an embedded swap widget safe for my visitors?

It can be, if you choose a non-custodial provider and lock down the frame. Validate message origins, avoid wildcards, use sandbox and a frame-src rule, and never accept a widget that asks for private keys or seed phrases.

Will I earn money from swaps made on my site?

Only if the provider offers revenue sharing and you configure it. Documentation for at least one widget states that an affiliate ID must be set during setup, so check before launch and confirm how and when payouts happen.

Does embedding a widget make me responsible for KYC or AML?

It depends on your country and on who operates the swap. If the provider runs the regulated activity and you only display its interface, your duties are usually lighter, but adding your own fees, custody or instructions can change that. Ask a lawyer who handles crypto and money transmission in your jurisdiction.

Sources

Start accepting crypto today

Open a free CryptoPayr account and take your first crypto payment the same day.

Get started for free

Keep reading

📝 Guides

How to Set Crypto Payment Limits for Your Business

Learn how to set crypto payment limits as a merchant: per-payment caps, daily totals, confirmation tiers and compliance triggers, with worked examples.

Oct 23, 2026 · 13.00 min Read →
📝 Guides

Crypto Payment Receipts: What They Must Contain

What a crypto payment receipt should contain, how to generate one, and which records a US business must keep for the IRS, with a ready-to-use field checklist.

Oct 22, 2026 · 14.00 min Read →
📝 Guides

How to Reduce Crypto Gas Fees in 2026: Payers and Merchants

Gas fees on Ethereum are far lower in 2026. Learn how timing, Layer 2s, gas settings and fee sponsorship cut what you or your customers pay.

Oct 21, 2026 · 11.00 min Read →