Overview
This guide will walk you through building a basic cross-chain swap interface using the Spice Flow SDK. You’ll have a working application where users can swap assets across different chains without bridging. What you’ll build:- A wallet connection button
- A swap interface supporting multiple chains
- Cross-chain transaction execution
Step 1: Installation
Install the Spice Flow SDK and your preferred wallet provider:Step 2: Setup Provider
Create a new component and wrap it withSpiceFlowProvider:
Step 3: Add Wallet Connection
Import and add theProviderLogin component:
Step 4: Add the Swap Widget
Add theSwapWidget component to enable cross-chain swaps:
Complete Example
Here’s a complete Next.js example:Environment Setup
Create a.env.local file in your project root:
- Privy: Sign up at privy.io and create an app
- Dynamic: Sign up at dynamic.xyz and get your environment ID
- Para: Sign up at getpara.com and get your API key
Test Your App
-
Start your development server:
-
Open your browser to
http://localhost:3000 - Connect your wallet using the login button
- Try a swap using the swap widget
Congratulations! You’ve built your first Spice Flow app. Users can now swap assets across chains without bridging.
What’s Next?
Components
Explore all available components and their props
Hooks
Build custom UIs with React hooks
Native Swap Example
Build a complete swap application with custom logic
Styling
Customize the appearance to match your brand
Configuration
Configure chains, providers, and more
How It Works
Understand the technical architecture
Using Other Wallet Providers
Dynamic
Para
Troubleshooting
”Window is not defined” Error
If you see this error in Next.js, ensure you’re using the"use client" directive and checking for window:
Wallet Not Connecting
- Check that your provider credentials are correct in
.env.local - Ensure you’re using the correct provider name (
"privy","dynamic", or"para") - Check the browser console for any error messages
Need More Help?
Join our Discord
Get help from the community and our team
