@yativo/crypto-sdk-react
v1.0.2
Published
Official React hooks and components for Yativo Crypto SDK
Maintainers
Readme
Yativo Crypto SDK - React
React hooks and components for the Yativo Crypto Platform. Accept and move USDC on Solana and USDC on XDC from your React app.
Installation
npm install @yativo/crypto-sdk-react
# or
yarn add @yativo/crypto-sdk-reactQuick Start
1. Wrap your app with YativoProvider
import { YativoProvider } from '@yativo/crypto-sdk-react';
function App() {
return (
<YativoProvider config={{ baseURL: 'https://crypto-api.yativo.com' }}>
<YourApp />
</YativoProvider>
);
}2. Passwordless authentication
Yativo uses passwordless auth — users enter their email, receive a one-time code, then optionally verify with a 2FA app or passkey.
import { useYativo } from '@yativo/crypto-sdk-react';
function LoginForm() {
const { login, verifyOTP } = useYativo();
// Step 1: request OTP — sends a code to user's email
const handleEmailSubmit = async (email: string) => {
await login(email);
// prompt user to enter OTP
};
// Step 2: verify OTP — sets access token on success
const handleOTPSubmit = async (otp: string) => {
await verifyOTP(otp);
};
return (/* ... your form ... */);
}3. Use hooks in your components
import { useYativo, useWallets, useTransactions } from '@yativo/crypto-sdk-react';
function Dashboard() {
const { user, isAuthenticated, logout } = useYativo();
const { wallets, loading, createWallet } = useWallets();
const { transactions, sendTransaction } = useTransactions();
if (!isAuthenticated) {
return <LoginForm />;
}
return (
<div>
<h1>Welcome {user?.email}</h1>
<div>
<h2>Your Wallets</h2>
{wallets.map(wallet => (
<div key={wallet.asset_id}>
{wallet.ticker}: {wallet.wallet_address}
</div>
))}
<button onClick={() => createWallet({ chain: 'solana', ticker: 'USDC_SOL' })}>
Add USDC on Solana
</button>
<button onClick={() => createWallet({ chain: 'xdc', ticker: 'USDC_XDC' })}>
Add USDC on XDC
</button>
</div>
<button onClick={logout}>Logout</button>
</div>
);
}Supported Assets
| Asset | Chain | Finality | |-------|-------|----------| | USDC_SOL | Solana | ~2–5 seconds | | USDC_XDC | XDC Network | ~2 seconds, near-zero fees |
Available Hooks
useYativo()
Access SDK instance, auth state, and passwordless auth methods (login, verifyOTP, verify2FA, logout).
useWallets(accountId?)
Manage user wallets.
useTransactions(params?)
List and send transactions.
useBalance(assetId, autoRefresh?)
Get wallet balance with auto-refresh.
Full Documentation
See main SDK documentation for complete API reference.
