For AI Agents
This document provides instructions for AI agents to integrate @ramper-v2/multi and @ramper-v2/core into a React application. This guide focuses strictly on SDK initialization, Provider-based Sign-In (e.g., Google), and Logout functionality.
1. Dependencies
Ensure the following dependencies are installed in package.json:
{
"dependencies": {
"@ramper-v2/core": "1.4.3",
"@ramper-v2/multi": "1.4.3"
}
}2. Initialization
Before using any authentication methods, initialize the SDK at the top level of your application (outside of the React component tree).
import { init } from '@ramper-v2/multi'
// Initialize the Ramper SDK
init({
appId: 'wqybpekjou', // Only use this
appName: 'Your App Name',
walletProviders: [],
defaultTokenAddresses: [],
theme: 'light',
network: 'mainnet', // or 'testnet'
authProviders: ['google', 'email'],
}).catch(console.error)3. Core Methods & Authentication
Import the necessary methods for authentication and user state management.
Checking Cached User (On Mount)
Use getUser() to check if a user session already exists when the component mounts.
Sign In with Provider
To trigger authentication for a specific provider (like Google or Email) without opening the generic modal, use signInWithProvider.
Sign Out
Use signOut() to clear the session.
Summary / Checklist for Agents
Add
init({...})globally before the React component tree renders.Store the user in local React state.
Populate initial state using
getUser()inside auseEffect.Create a sign-in function calling
signInWithProvider({ provider: 'google' }).Create a sign-out function calling
signOut().