Use @coin-voyage/swapkit when you want to add token swap capabilities to your application. It gives your users an embeddable interface for connecting a wallet, selecting source and destination tokens, requesting a quote, configuring slippage, executing the swap, and tracking its status.
SwapKit is independent from the SALE and DEPOSIT payment flows provided by PayKit. If your application needs to accept customer payments or fund a specified wallet or account, use @coin-voyage/paykit.
Installation
Install SwapKit with its core peer dependencies:
Install the wallet peer dependencies listed by @coin-voyage/swapkit for the chains your application supports. SwapKit uses styled-components and does not require Tailwind CSS.
Wrap Swap with the re-exported WalletProvider and SwapKitProvider:
defaultSourceCurrency and defaultDestinationCurrency accept a chain ID and an optional token address. Defaults are read when the widget mounts; remount the widget with a new React key to apply changed defaults.
- Use
defaultSlippageBps to start with a custom slippage tolerance. When you omit it, SwapKit lets the quote service choose the tolerance automatically.
- Use
onComplete to receive the completed swap’s orderId and transactionHash.
- Use
onError to surface execution errors in your application.
- Set
mode on SwapKitProvider to "light", "dark", or "auto", and pass theme to override individual widget colors.
SwapKitProvider uses the public API client and accepts an API key, but never an
admin signing key.