A comprehensive wallet connection kit for Stellar dApps
npm install stellar-wallet-kitbash
npm install stellar-wallet-kit
or
yarn add stellar-wallet-kit
or
pnpm add stellar-wallet-kit
`
---
π Quick Start
$3
`tsx
import { WalletProvider, NetworkType } from 'stellar-wallet-kit';
export function App() {
return (
config={{
network: NetworkType.TESTNET,
autoConnect: true,
}}
>
);
}
`
---
$3
`tsx
import { ConnectButton } from 'stellar-wallet-kit';
export function Header() {
return ;
}
`
---
$3
`tsx
import { useWallet } from 'stellar-wallet-kit';
function Dashboard() {
const { account, isConnected, signTransaction } = useWallet();
if (!isConnected) return Please connect your wallet
;
return (
Connected: {account.address}
);
}
`
---
π Supported Wallets
| Wallet | Type | Connection Model | Auto-Reconnect |
| ----------------- | ----------------- | ---------------------- | -------------- |
| Freighter | Browser extension | Injected API | β
|
| Albedo | Web wallet | Popup + callback | β |
| WalletConnect | Mobile wallets | QR / deep-link session | β
|
| LOBSTR | Mobile wallet | WalletConnect | β
|
> LOBSTR is exposed separately in the UI but internally uses WalletConnect.
---
π WalletConnect & LOBSTR (Important)
WalletConnect does not block the UI like extensions.
* QR modal stays visible
* SDK tracks connectingWallet
* Global loaders do not cover WalletConnect
This avoids the βQR hidden behind loaderβ problem by design.
---
$3
`tsx
import { WalletType, useWallet } from 'stellar-wallet-kit';
const { connect } = useWallet();
await connect(WalletType.WALLETCONNECT);
await connect(WalletType.LOBSTR);
`
---
π Albedo Wallet Integration (Required)
Albedo is a web-based wallet and requires a callback route.
If the callback is missing:
* Albedo opens
* User approves
* Connection never completes
This is expected behavior.
---
$3
1. App opens Albedo popup
2. User approves
3. Albedo redirects to callback URL
4. Callback posts message to opener
5. Popup closes
6. Wallet connects
---
$3
#### Next.js (App Router)
`tsx
// app/albedo-callback/page.tsx
'use client';
import { useEffect } from 'react';
export default function AlbedoCallback() {
useEffect(() => {
const params = Object.fromEntries(
new URLSearchParams(window.location.search)
);
if (window.opener) {
window.opener.postMessage(
{ type: 'ALBEDO_RESULT', payload: params },
window.location.origin
);
}
window.close();
}, []);
return Connecting walletβ¦
;
}
`
---
π° Balance Utilities
`tsx
import {
getNativeBalance,
getAssetBalance,
formatBalance,
hasSufficientBalance,
} from 'stellar-wallet-kit';
const xlm = getNativeBalance(account.balances);
const usdc = getAssetBalance(account.balances, 'USDC', issuer);
`
---
π¨ Theme Customization
`tsx
config={{
theme: {
mode: 'dark',
primaryColor: '#8b5cf6',
borderRadius: '16px',
},
}}
>
`
---
π―
useWallet() API
`ts
const {
account,
isConnected,
isConnecting,
connectingWallet,
error,
network,
selectedWallet,
availableWallets,
connect,
disconnect,
signTransaction,
signAuthEntry,
switchNetwork,
refreshBalances,
supports,
} = useWallet();
`
---
π§ Wallet Capabilities (
supports)
`ts
supports = {
silentReconnect: boolean;
networkDetection: boolean;
authEntrySigning: boolean;
}
``