Installation & setup
Install the SDK, set up providers, and verify everything works
Prerequisites
Installation
Choose your preferred package manager:
bashnpm install @b3dotfun/sdk
bashpnpm add @b3dotfun/sdk
Basic Setup
1. Provider Setup
Wrap your app with the B3Provider and AnyspendProvider to enable AnySpend functionality:
tsximport { AnyspendProvider } from "@b3dotfun/sdk/anyspend/react"; import { B3Provider } from "@b3dotfun/sdk/global-account/react"; import "@b3dotfun/sdk/index.css"; function App() { return ( <B3Provider theme="light" environment="production" partnerId="your-awesome-partner-id"> <AnyspendProvider>{/* Your app components */}</AnyspendProvider> </B3Provider> ); } export default App;
2. Environment Configuration
Endpoint: https://mainnet.anyspend.com
Use this for production applications with real transactions.
Endpoint: http://testnet.anyspend.com
Use this for development and testing with test tokens.
Note: Testnet is currently not available.
3. TypeScript Configuration (Optional but Recommended)
If you're using TypeScript, ensure your tsconfig.json includes these settings for optimal compatibility:
json{ "compilerOptions": { "moduleResolution": "node", "allowSyntheticDefaultImports": true, "esModuleInterop": true } }
Verification
Create a simple test component to verify your setup works correctly:
tsximport { AnySpend } from "@b3dotfun/sdk/anyspend/react"; function TestComponent() { return <AnySpend />; }
Next Steps
Troubleshooting
Make sure you've installed the SDK correctly and imported the CSS file. The SDK requires React 18+ and may have compatibility issues with older versions.
Ensure you have B3Provider and AnyspendProvider placed high in your component tree, typically in your main App component.
If you're seeing TypeScript errors, verify your tsconfig.json includes the recommended settings above.