Guide

Web framework examples · Solana / USDC

React, Next.js, Vue, and Vanilla patterns for embedding the MoneyGram Ramps widget after the core Web guide. Pick a tab for your stack.

Tabs by frameworkWeb · SolanaUSDC

MoneyGram Ramps: Web framework examples (Solana / USDC)

Companion to the Web · Solana guide.

Runnable reference for the full Solana widget flow: Solana hub · clone and run on devnet. The tabbed snippets below are minimal embed patterns for an existing app.

React

TSX
import { useEffect, useRef, useState } from 'react' // Type definitions (add to your project)interface OnChainTransaction {  chain: string  to: string  amount: string  asset: string  memo?: string  rawTransaction: unknown} interface RampsSDK {  open(): void  close(): void  destroy(): void} // SDK loaded via <script> tag in index.htmldeclare const RampsSDK: {  createRamps: (config: any) => RampsSDK} const { createRamps } = RampsSDK function CashOutButton() {  const containerRef = useRef<HTMLDivElement>(null)  const rampsRef = useRef<RampsSDK | null>(null)  const [isOpen, setIsOpen] = useState(false)    async function handleOpenWidget() {    if (!containerRef.current) return        // Check if user is authenticated in your wallet    if (!yourWallet.isConnected()) {      alert('Please sign in to your wallet first')      return    }        // Fetch session    const session = await fetch('/api/moneygram-session', { method: 'POST' })      .then(res => res.json())        // Create widget    const ramps = createRamps({      container: containerRef.current,      sessionToken: session.sessionToken,      widgetUrl: session.widgetUrl,            wallet: {        address: yourWallet.getPublicKey(),        chain: 'solana',        asset: 'USDC',        walletType: 'non-custodial'      },            onSignTransaction: async (tx: OnChainTransaction) => {        return await signAndSendUsdc(tx)      },            onComplete: (transaction) => {        alert(`Cash pickup code: ${transaction.referenceNumber}`)        setIsOpen(false)      },            onClose: () => {        setIsOpen(false)      }    })        rampsRef.current = ramps    ramps.open()    setIsOpen(true)  }    // Cleanup on unmount  useEffect(() => {    return () => {      rampsRef.current?.destroy()    }  }, [])    return (       <button onClick={handleOpenWidget} disabled={isOpen}>        Cash Out USDC      </button>            {/* Container for widget iframe */}     </div>  )}