This guide will help you quickly set up and integrate the Sage SDK into your React application. Follow these steps to begin building decentralized social experiences with Sage.
Use built-in React hooks and the SageProvider to manage state in your React app:
Copy
import { SageProvider } from '@sageprotocol/sdk/react';const App = () => ( <SageProvider appId="your-app-id" // Unique app context (required) channelRegistryId="your-registry-id" // Channel registry ID (required) network="testnet" // 'mainnet' or 'testnet' (default: 'mainnet') > {/* Your app components here */} </SageProvider>);export default App;
Your React application must handle wallet connections for transaction signing. Ensure your users connect their Sui wallet, and your app can request and execute signatures properly.
Direct Javacript Integration Example
Copy
import { SageClient } from '@sageprotocol/sdk';const sage = new SageClient({ appId: 'your-app-id', // explicitly required unique app context channelRegistryId: 'your-registry-id', // required channel registry ID network: 'testnet' // or 'mainnet' (default: 'mainnet')});await sage.initialize();