Integrate zkLogin into your Stellar dApp in 6 simple steps. No external wallets required.
Step 1 of 6
STEP 1
Add the zkLogin SDK to your Stellar dApp
The SDK is a single package with zero external wallet dependencies
Works with any JavaScript/TypeScript project
React components included (optional)
1# Using npm2npm install @stellar-zklogin/sdk34# Using pnpm5pnpm add @stellar-zklogin/sdk67# Using yarn8yarn add @stellar-zklogin/sdknpm i @stellar-zklogin/sdknew StellarZkLogin(config)zkLogin.login('google')Copy this to get started immediately
import { StellarZkLogin } from '@stellar-zklogin/sdk';
// 1. Initialize SDK
const zkLogin = new StellarZkLogin({
network: 'testnet',
oauth: {
google: { clientId: 'YOUR_GOOGLE_CLIENT_ID' }
}
});
// 2. Login user with Google
async function handleLogin() {
try {
const wallet = await zkLogin.login('google');
console.log('✓ Logged in!');
console.log('Address:', wallet.getAddress());
console.log('Balance:', await wallet.getBalance(), 'XLM');
return wallet;
} catch (error) {
console.error('Login failed:', error);
}
}
// 3. Send payment
async function sendPayment(wallet, to, amount) {
const result = await wallet.sendPayment(to, 'native', amount);
console.log('✓ Payment sent!');
console.log('TX Hash:', result.hash);
return result;
}
// 4. Listen for events
zkLogin.on('login', (data) => {
console.log('User logged in:', data.address);
});
zkLogin.on('logout', () => {
console.log('User logged out');
});
// 5. Logout
function handleLogout() {
zkLogin.logout();
}
// Usage
const wallet = await handleLogin();
await sendPayment(wallet, 'GDESTINATION...', '10');Start integrating zkLogin into your Stellar dApp today. No external wallets. No complexity. Just code.