POWERED BY X-RAY PROTOCOL 25

SDK JOURNEY

Integrate zkLogin into your Stellar dApp in 6 simple steps. No external wallets required.

Step 1 of 6

STEP 1

Install the SDK

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)

bash
1# Using npm
2npm install @stellar-zklogin/sdk
3
4# Using pnpm
5pnpm add @stellar-zklogin/sdk
6
7# Using yarn
8yarn add @stellar-zklogin/sdk

QUICK REFERENCE

INSTALL

npm i @stellar-zklogin/sdk

INITIALIZE

new StellarZkLogin(config)

LOGIN

zkLogin.login('google')

COMPLETE EXAMPLE

Copy this to get started immediately

app.tsx
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');

READY TO BUILD?

Start integrating zkLogin into your Stellar dApp today. No external wallets. No complexity. Just code.