@sodax/sdk in a Next.js project, from project creation to using the SDK features.
Prerequisites
- Node.js 18+ installed
- npm, yarn, or pnpm package manager
- Basic knowledge of Next.js and TypeScript
Step 1: Create Your Project
First, create a new Next.js project with TypeScript:Step 2: Install @sodax/sdk
Install the SODAX SDK and its peer dependencies:Step 3: Create Sodax Instance
Create a Sodax instance provider. Createproviders/SodaxProvider.tsx:
app/layout.tsx to include the SodaxProvider:
Step 4: Start Your Build Process
Start the development server:http://localhost:3000.
Step 5: Start Using @sodax/sdk
Now you can use the SODAX SDK in your components. Here’s an example of how to use it:TypeScript Configuration
Make sure yourtsconfig.json includes the necessary paths for the @ alias:
Next Steps
Now that you have@sodax/sdk set up in your Next.js project, you can:
- Explore Solver Features: Check out the Swaps documentation for cross-chain swaps
- Explore Money Market Features: Check out the Money Market documentation for lending and borrowing
- Set up Wallet Integration: Implement wallet providers for the chains you want to support
- Add Error Handling: Implement proper error handling for SDK operations
- Add Loading States: Add loading indicators for async operations
Troubleshooting
Common Issues
-
TypeScript Errors: Make sure you have the latest version of TypeScript and that your
tsconfig.jsonis properly configured. - Import Errors: Ensure all imports are using the correct paths and that the packages are properly installed.
Getting Help
If you encounter any issues:- Check the main SDK documentation
- Review the Swaps documentation for swap-related features
- Review the Money Market documentation for lending/borrowing features
- Open an issue on the GitHub repository
- Join the Discord community for support