@aurora-is-near/intents-swap-widget

中文文档
7.29.0发布于 2026/11/03MITTypeScriptES Module近 30 天下载 8734

Provides components and hooks to build your own Intents swap widget

原始使用文档
文档目录14 节
  1. Contents
  2. At a glance
  3. Widget Studio
  4. Choose your integration
  5. Quick start
  6. How it works
  7. Wallets and chain adapters
  8. Configuration
  9. Widgets and events
  10. Theming and localisation
  11. Subpath exports (build your own UI)
  12. Troubleshooting
  13. Documentation map
  14. License

@aurora-is-near/intents-swap-widget

Intents Swap Widget: sell USDC on Base, buy AURORA

npm Widget Studio Docs

A React cross-chain swap widget powered by NEAR Intents. Drop it into your app and let users swap any supported asset across 35+ chains from a single UI, while you earn fees on every swap.

[!TIP] Just need a working widget with wallet connection built in? Use @aurora-is-near/intents-swap-widget-standalone. This package (the core) is for apps that already connect wallets and want full control.

Contents

At a glance

WhatA React swap UI plus the hooks, state machine and components behind it
RoutingNEAR Intents via the Aurora Intents API (1Click-compatible)
Chains35+: EVM chains, Solana, NEAR, Stellar, TON, Bitcoin, Sui, Tron, XRP and more (full list)
AssetsAnything the Intents API lists (supported assets)
RequiresReact >=18.2, an API key from Widget Studio
WalletsYou bring them: pass addresses and providers in (see Wallets)
FeesSet per API key in Studio, or per swap with appFees
PrivacyOptional confidential swaps (confidentialMode)

Widget Studio

Widget Studio is a no-code dashboard for the widget. Use it to:

  • 🔑 Get your API key. It is required, and it is also where your fees are configured.
  • 🌐 Pick networks and tokens, set default sell/buy tokens, and choose confidentiality mode.
  • 🎨 Design it: Clean or Bold style, accent and background colours, corner radius, container.
  • 👀 Preview it live before shipping.
  • 📦 Embed it: Embed in your app gives you an iframe link or a ready-to-paste React snippet.
  • 📊 Download reports of swaps made with your API keys (CSV).

Widget Studio: live widget preview on the left, networks, tokens and confidentiality settings on the right

[!NOTE] The API key is not secret. It is safe to ship in front-end code.

Choose your integration

flowchart TD
    A[I want a swap widget in my app] --> B{Need code-level control?}
    B -- No --> IF["<b>iframe</b><br/>Copy the link from Widget Studio"]
    B -- Yes --> C{Does your app already<br/>connect wallets?}
    C -- No --> SA["<b>@aurora-is-near/intents-swap-widget-standalone</b><br/>Wallet modal built in"]
    C -- Yes --> CORE["<b>@aurora-is-near/intents-swap-widget</b><br/>+ chain adapters you need"]
iframeStandalone packageCore package (this one)
Setup effort1 line~5 linesModerate
Wallet connectionBuilt inBuilt in (AppKit, NEAR Connect, Stellar Wallets Kit)Yours
TON wallets–❌✅
Hooks and events (onMsg)❌✅✅
Custom transfers (makeTransfer)❌✅✅
Bundle size control–All chain SDKs includedOnly adapters you install

Quick start

1. Install the core package and the adapter for each chain family your wallets support:

npm install @aurora-is-near/intents-swap-widget
# Add only what you need:
npm install @aurora-is-near/intents-swap-widget-evm      # Ethereum, Base, Arbitrum, …
npm install @aurora-is-near/intents-swap-widget-solana   # Solana
npm install @aurora-is-near/intents-swap-widget-stellar  # Stellar

2. Render the widget inside WidgetConfigProvider:

import '@aurora-is-near/intents-swap-widget/styles.css';

import {
  Widget,
  WidgetConfigProvider,
} from '@aurora-is-near/intents-swap-widget';
import { evm } from '@aurora-is-near/intents-swap-widget-evm';

export function Swap() {
  const { address, connect, disconnect } = useYourEvmWallet(); // your wallet lib

  return (
    <WidgetConfigProvider
      config={{
        apiKey: 'YOUR_STUDIO_API_KEY',
        connectedWallets: { default: address },
        providers: { evm: window.ethereum }, // any EIP-1193 provider
        plugins: { evm },
        onWalletSignin: connect,
        onWalletSignout: disconnect,
      }}
      theme={{ colorScheme: 'dark', accentColor: '#bc9cf8' }}>
      <Widget />
    </WidgetConfigProvider>
  );
}

That's a working swap widget. Next: add more chains, restrict tokens, or match your brand.

How it works

The widget never holds user funds. Each swap is a quote → deposit → settle flow:

sequenceDiagram
    autonumber
    actor U as User
    participant W as Swap Widget
    participant API as Aurora Intents API
    participant P as Chain adapter + wallet
    participant NI as NEAR Intents

    U->>W: Pick tokens and amount
    W->>API: Request quote (apiKey, fees, slippage)
    API-->>W: Quote + one-time deposit address
    U->>W: Click "Swap"
    W->>P: makeTransfer(amount → deposit address)
    P-->>W: Transaction hash (user signs in wallet)
    NI->>NI: Solvers fill the intent
    W->>API: Poll swap status
    API-->>W: Success, funds sent to recipient

The chain adapter (plugins.evm, plugins.sol, …) only handles step 5: sending funds from the user's wallet to the deposit address on the source chain. The rest is shared by all chains.

Wallets and chain adapters

The core package does not bundle chain SDKs. You pass three things for each chain family:

Config keyWhat it is
connectedWalletsAddresses keyed by chain, e.g. { default: '0x…', sol: '…', ton: 'UQ…' }. The widget uses the selected token's chain, falling back to default.
providersSigners the widget uses: evm, sol, stellar, near
pluginsAdapter per chain family that performs the deposit transfer
Source chain familyAdapter packageplugins keyproviders value
EVM (Ethereum, Base, Arbitrum, BSC, Polygon, Optimism, Avalanche, Aurora, …)intents-swap-widget-evmevmEIP-1193 provider, or () => Promise<provider>
Solanaintents-swap-widget-solanasol{ publicKey, signMessage, signTransaction }
Stellarintents-swap-widget-stellarstellar{ publicKey, signMessage, signTransaction }
NEARBuilt in, no adapter needed–() => nearWallet
TON and othersNone: pass your own makeTransfer to the widget––

Any supported chain can be a destination, whether or not the user has a wallet for it. With allowSwapWithExternalWallet, users can also deposit from any chain by sending to a QR-code address.

Multi-chain example (EVM + Solana + Stellar + NEAR + TON)
import { evm } from '@aurora-is-near/intents-swap-widget-evm';
import { sol } from '@aurora-is-near/intents-swap-widget-solana';
import { stellar } from '@aurora-is-near/intents-swap-widget-stellar';

const config = {
  apiKey: 'YOUR_STUDIO_API_KEY',
  connectedWallets: {
    default: evmAddress,
    sol: solanaAddress,
    stellar: stellarAddress,
    near: nearAccountId,
    ton: tonAddress,
  },
  providers: {
    evm: window.ethereum,
    sol: { publicKey, signMessage, signTransaction },
    stellar: { publicKey: stellarAddress, signMessage, signTransaction },
    near: () => nearWallet,
  },
  plugins: { evm, sol, stellar },
  onWalletSignin: openWalletModal,
  onWalletSignout: disconnect,
};

Adapter guides for Privy, NEAR and TON: 📖 Wallet Connection docs.

Configuration

Everything goes through the config prop of WidgetConfigProvider. Other props: theme, localisation, rpcs, balanceViaRpc. These are the options most integrations use:

OptionTypePurpose
apiKeystringRequired. Your key from Widget Studio
appFees{ recipient, fee }[]Extra fees in basis points, sent to a NEAR Intents account
allowedTokensListstring[]Only allow these tokens (asset IDs or symbols) on both sides
allowedSourceTokensList / allowedTargetTokensListstring[]Same, for one side only
allowedChainsListChains[]Only allow these chains, e.g. ['eth', 'base', 'sol']
defaultSourceToken / defaultTargetTokentoken or nullPreselected tokens
slippageTolerancenumberIn bps: 100 = 1%
sendAddressstringFixed recipient (defaults to the sender's address)
confidentialMode'public' | 'confidential' | 'user-choice'Confidential swaps
allowSwapWithExternalWalletbooleanAdds a QR-code deposit option for any chain
alchemyApiKeystringMore reliable balances and Solana RPC (recommended in production)
tonCenterApiKeystringTON balances
fetchQuotefnProxy quotes through your own backend
<WidgetConfigProvider
  config={{
    apiKey: 'YOUR_STUDIO_API_KEY',
    allowedChainsList: ['eth', 'base', 'arb', 'sol', 'near'],
    allowedTokensList: ['USDC', 'USDT', 'ETH', 'SOL'],
    appFees: [{ recipient: 'your-app.near', fee: 20 }], // 0.2%
    slippageTolerance: 50, // 0.5%
  }}>
  <Widget />
</WidgetConfigProvider>

📖 Full reference (40+ options): Widget Configuration docs. An in-repo copy lives at docs/configuration.md, and the WidgetConfig type is in src/types/config.ts. yarn check-docs keeps the doc and the type in sync.

Chain IDs used in config (allowedChainsList, connectedWallets keys, …)
FamilyIDs
EVMeth base arb bsc pol op avax gnosis bera monad adi plasma scroll xlayer hood aurora
Non-EVMnear sol stellar ton btc sui xrp doge tron zec ltc cardano aleo bch dash starknet hypercore qtc

Source: src/constants/chains.ts.

Widgets and events

ComponentUse it for
WidgetThe default. Full widget with settings and history. defaultMode: 'swap' (default) or 'topup'
WidgetSwapSwap form only
WidgetDepositModeTop-up form: receive a fixed token, pay from a wallet or an external-wallet QR code
WidgetDeposit / WidgetWithdrawMoving funds into or out of your app's Intents account (enableAccountAbstraction)

Events: listen to the transfer pipeline with onMsg:

<Widget
  onMsg={(msg) => {
    if (msg.type === 'on_transfer_success') {
      analytics.track('swap', { hash: msg.hash });
    }
  }}
/>

Custom transfers: send the deposit yourself (e.g. for TON) and return the hash:

<Widget
  makeTransfer={async (args) => {
    const hash = await sendTon(args.address, args.amount);
    return { hash, transactionLink: `https://tonviewer.com/transaction/${hash}` };
  }}
/>

📖 Widgets docs

Theming and localisation

ApproachHowDocs
Theme object (recommended)theme={{ colorScheme, accentColor, backgroundColor, stylePreset: 'clean' | 'bold', borderRadius, showContainer }}Theming
CSS variablesOverride --sw-* variables. Full list: src/theme.cssTheming
Copy / i18nlocalisation={{ 'submit.active.swap': 'Swap now' }}. All keys: src/types/localisation.tsLocalisation

[!IMPORTANT] Always import @aurora-is-near/intents-swap-widget/styles.css. If your app has a global CSS reset, wrap it in @layer base { … }, otherwise Tailwind layering removes the widget's spacing.

Subpath exports (build your own UI)

Use the pieces directly if the pre-built widgets don't fit your use case:

ImportContains
@aurora-is-near/intents-swap-widgetEverything below, plus Widget* and WidgetConfigProvider
…/componentsStateless UI kit: buttons, inputs, banners
…/featuresRich components that use widget context (e.g. SwapQuote)
…/hooksLogic without UI (e.g. useTokens)
…/machineFinite state machine and store, the core of the business logic
…/typesDomain types: Token, Chains, Quote, WidgetConfig, …
…/extOptional integrations (e.g. useAlchemyBalanceIntegration)
…/constants · …/utils · …/configConstants, helpers, config store
…/styles.css · …/tailwind.css · …/theme.cssStyles (bundled, Tailwind source, variables only)

Troubleshooting

SymptomFix
EVM transfers are not supported. Add the EVM plugin … (or Solana / Stellar)Install the adapter and add it to plugins
… Add an EVM provider via the providers configuration propertyPass the wallet signer in providers
Button says "Connect wallet" and can't be clickedProvide onWalletSignin
Balances load foreverAdd alchemyApiKey. For TON, add tonCenterApiKey
No styles or broken spacingImport styles.css, and scope your CSS reset with @layer base
Duplicate dependency errors (valtio, @reown/*, @solana/*)Pin versions with resolutions / overrides

📖 Troubleshooting docs · Open an issue

Documentation map

Where to goFor
Monorepo READMEAll packages, development setup, contributing
-standalone · -evm · -solana · -stellarWallet-included widget and chain adapters
What is Swap Widget?Product overview
Widget integrationStudio walkthrough (iframe or React)
API Keys & FeesFee split, limits, reports
Supported chains · assetsWhat can be swapped
llms.txt🤖 Machine-readable index of all docs. Add .md to any docs URL to get Markdown

License

MIT

版本与发布记录

@aurora-is-near/intents-swap-widget 共发布 399 个版本,首次发布于 2025/08/22;过去 12 个月发布了 257 个版本。

版本发布日期距今
7.29.0latest2026/11/035 天前
7.28.02026/10/2910 天前
7.27.12026/10/2612 天前
7.27.02026/10/1523 天前
7.26.02026/10/1325 天前
7.25.12026/10/081 个月前

其他发布通道:redesign → 3.14.0-redesign.12。

关于 @aurora-is-near/intents-swap-widget 的常见问题

@aurora-is-near/intents-swap-widget 是什么?

Provides components and hooks to build your own Intents swap widget

如何安装 @aurora-is-near/intents-swap-widget?

在项目目录运行 npm install @aurora-is-near/intents-swap-widget,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=18.2.0)、react-dom(>=18.2.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@aurora-is-near/intents-swap-widget 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@aurora-is-near/intents-swap-widget 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@aurora-is-near/intents-swap-widget 可以商用吗?

@aurora-is-near/intents-swap-widget 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@aurora-is-near/intents-swap-widget 的下载量有多少?

根据 npm 官方下载统计,@aurora-is-near/intents-swap-widget 在 2026/10/07 – 2026/11/05 这 30 天内被下载 8,734 次,日均约 291 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@aurora-is-near/intents-swap-widget 还在维护吗?

最新版本 7.29.0 发布于 2026/11/03(5 天前);至今共发布 399 个版本,其中过去 12 个月发布了 257 个;首次发布于 2025/08/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。