Skip to main content
The Hypermid Widget embeds the full Hypermid experience into any website — swap, bridge, gas refuel, and buy crypto with card. It uses the same production app at hypermid.io, loaded as an iframe.
The widget includes full wallet connection (550+ wallets via Reown/WalletConnect) supporting EVM, Solana, Bitcoin, TON, TRON, and SUI — no additional setup needed.

Features

  • Cross-chain swap & bridge — 90+ chains, best route comparison
  • On-ramp — Buy crypto with card via RampNow (USD, EUR, GBP, and more)
  • Gas refuel — Top up gas on any chain
  • Wallet connection — MetaMask, WalletConnect, Coinbase, Trust Wallet, Binance, and 550+ more
  • Full theme customization — Colors, borders, radius, fonts, shadows
  • Event callbacks — Quote, execute, status, error events via postMessage
  • Auto-resize — Iframe height adjusts to content
  • Mode toggle — Users can switch between Swap, Gas, and Fund modes

Quick Start

Script Tag (Any Website)

<div id="hypermid-widget"></div>

<script src="https://widget.hypermid.io/v1/embed.js"></script>
<script>
  HypermidWidget.init({
    containerId: "hypermid-widget",
    partnerId: "your-partner-id",
    theme: "dark",
    defaultFromChain: 1,
    defaultToChain: 42161,
  });
</script>

Data Attribute (Zero JS)

For even simpler integration — no JavaScript needed:
<div
  id="hypermid-widget"
  data-hypermid-widget
  data-partner-id="your-partner-id"
  data-theme="dark"
  data-from-chain="1"
  data-to-chain="42161"
></div>

<script src="https://widget.hypermid.io/v1/embed.js"></script>

Direct Iframe

If you prefer full control, embed the iframe directly:
<iframe
  src="https://www.hypermid.io/widget?partnerId=your-partner-id&theme=dark&fromChain=1&toChain=42161&embed=1"
  width="420"
  height="700"
  frameborder="0"
  allow="clipboard-write; payment; web-share"
  style="border: none; border-radius: 16px; box-shadow: 0 4px 24px rgba(0,0,0,0.15);"
></iframe>
Do NOT add the sandbox attribute to the iframe — it will break wallet connections.

Configuration Options

Display

OptionTypeDefaultDescription
containerIdstringrequiredDOM element ID to mount into
partnerIdstringYour partner ID for fee tracking
theme"dark" | "light""dark"Widget color theme
mode"swap" | "gas" | "fund""swap"Initial active mode
widthstring"420px"Widget width
heightstring"700px"Widget height
hideOnrampbooleanfalseHide the mode toggle (swap/gas/fund)
hidePoweredBybooleanfalseHide “Powered by Hypermid”

Presets

OptionTypeDefaultDescription
defaultFromChainnumber1Default source chain ID
defaultToChainnumberDefault destination chain ID
defaultFromTokenstringDefault source token address
defaultToTokenstringDefault destination token address
defaultFromAmountstringDefault input amount
walletAddressstringPre-fill wallet address
lockFromChainbooleanfalseLock source chain selector
lockToChainbooleanfalseLock destination chain selector

Theme Customization

Override any visual aspect of the widget to match your brand:
OptionTypeDefaultDescription
accentColorstring"#44E1AA"CTA button & highlight color
accentHoverColorstringAccent hover state color
bgPrimarystringPage background color
bgCardstringCard background color
bgCardInnerstringInner card / token area background
bgInputstringInput field background
textPrimarystringPrimary text color
textSecondarystringSecondary text color
borderColorstringBorder color (format: "hex:opacity" e.g. "6C63FF:15")
borderRadiusnumber16Card corner radius in px
buttonRadiusnumber12Button corner radius in px
fontFamilystring"Sora"Font family name
shadowstringCard shadow CSS value (or "none")
Example — fully branded widget:
HypermidWidget.init({
  containerId: "swap",
  partnerId: "trust-wallet",
  theme: "dark",
  defaultFromChain: 1,
  defaultToChain: 42161,
  // Brand customization
  accentColor: "#FF6B35",
  bgPrimary: "#1A1A2E",
  bgCard: "#252540",
  borderRadius: 20,
  buttonRadius: 8,
  fontFamily: "Inter",
});

Wallet Connection

The widget includes built-in wallet connection via Reown AppKit — the same wallet infrastructure used by the main Hypermid app. No additional configuration needed. Supported wallet ecosystems:
EcosystemWallets
EVMMetaMask, WalletConnect QR, Coinbase, Trust Wallet, Binance, SafePal, Rainbow, and 500+ more
SolanaPhantom, Solflare, Backpack
BitcoinXverse, Leather, UniSat
TONTonkeeper, MyTonWallet
TRONTronLink
SUISui Wallet
When users click “Connect Wallet”, a modal appears with all supported wallets for the selected chain ecosystem. After connecting, the widget displays token balances and enables transaction signing.

On-Ramp (Buy Crypto)

The widget includes a built-in “Buy Crypto” tab powered by RampNow. Users can purchase crypto with their credit/debit card directly within the widget. To open the widget in on-ramp mode by default:
HypermidWidget.init({
  containerId: "hypermid-widget",
  partnerId: "your-partner-id",
  mode: "fund",  // Opens Buy Crypto tab
});
The on-ramp supports:
  • Fiat currencies: USD, EUR, GBP, and more
  • Crypto tokens: ETH, USDC, USDT, BTC, and 50+ tokens
  • Payment methods: Credit card, debit card, Apple Pay, Google Pay
  • KYC: Handled by RampNow within the flow
To hide the mode toggle and show only the swap UI, set hideOnramp: true. This removes the swap/gas/fund toggle at the top.

Event Callbacks

Listen for events from the widget:
HypermidWidget.init({
  containerId: "hypermid-widget",
  partnerId: "your-partner-id",

  onReady: function () {
    console.log("Widget loaded and ready");
  },

  onQuote: function (quote) {
    console.log("Quote received:", quote);
    // { fromToken, toToken, fromAmount, toAmount, provider, fee }
  },

  onExecute: function (result) {
    console.log("Swap executed:", result);
    // { txHash, provider, fromChain, toChain, status }
  },

  onStatusChange: function (status) {
    console.log("Status update:", status);
    // { status: "PENDING" | "PROCESSING" | "DONE" | "FAILED", txHash }
  },

  onError: function (error) {
    console.error("Widget error:", error);
    // { code, message }
  },
});
Events are communicated via window.postMessage from the iframe. The embed script handles the plumbing automatically.

Programmatic Control

After initialization, control the widget dynamically:
// Update configuration (rebuilds iframe)
HypermidWidget.update({
  theme: "light",
  defaultFromChain: 42161,
});

// Set swap parameters
HypermidWidget.setSwap({
  fromChain: 1,
  toChain: 137,
  fromToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
  fromAmount: "100",
});

// Change theme at runtime
HypermidWidget.postMessage("setTheme", { theme: "light" });

// Override CSS variables at runtime
HypermidWidget.postMessage("setStyle", {
  "--bg-card": "#1a1a2e",
  "--accent-cyan": "#ff6b35",
});

// Remove the widget
HypermidWidget.destroy();

React Integration

Wrap the embed script in a React component:
import { useEffect, useRef } from "react";

declare global {
  interface Window {
    HypermidWidget: any;
  }
}

interface HypermidWidgetProps {
  partnerId?: string;
  theme?: "dark" | "light";
  mode?: "swap" | "gas" | "fund";
  defaultFromChain?: number;
  defaultToChain?: number;
  accentColor?: string;
  onSwapComplete?: (result: any) => void;
  onError?: (error: any) => void;
}

export function HypermidWidget(props: HypermidWidgetProps) {
  const containerRef = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const script = document.createElement("script");
    script.src = "https://widget.hypermid.io/v1/embed.js";
    script.onload = () => {
      window.HypermidWidget.init({
        containerId: "hypermid-react-widget",
        partnerId: props.partnerId,
        theme: props.theme || "dark",
        mode: props.mode || "swap",
        defaultFromChain: props.defaultFromChain,
        defaultToChain: props.defaultToChain,
        accentColor: props.accentColor,
        onExecute: props.onSwapComplete,
        onError: props.onError,
      });
    };
    document.body.appendChild(script);

    return () => {
      window.HypermidWidget?.destroy();
      document.body.removeChild(script);
    };
  }, []);

  return <div id="hypermid-react-widget" ref={containerRef} />;
}
Usage:
<HypermidWidget
  partnerId="your-partner-id"
  theme="dark"
  mode="swap"
  defaultFromChain={1}
  defaultToChain={42161}
  accentColor="#FF6B35"
  onSwapComplete={(result) => console.log("Done!", result)}
/>

Supported Chains

The widget supports all chains available in the Hypermid app:
  • EVM: Ethereum, Arbitrum, Base, Polygon, Optimism, BSC, Avalanche, and 50+ more
  • Non-EVM: Solana, Bitcoin, TON, TRON, NEAR, XRP, Dogecoin, Litecoin, and more
  • On-ramp: Buy crypto with card on any supported chain
See Chain Support for the full list.

Best Practices

  1. Set default chains — Pre-select the most common pair for your users to reduce friction
  2. Use partnerId — Ensures fee tracking and higher rate limits for your integration
  3. Handle callbacks — Implement onExecute and onError to update your app state
  4. Don’t use sandbox — The iframe sandbox attribute breaks wallet connections
  5. Set height: 700px — The widget needs at least 700px height for the on-ramp form
  6. Lock chains if needed — Use lockFromChain/lockToChain for focused use cases
  7. Test in incognito — Your existing Hypermid session may auto-connect the wallet