A React SDK for integrating Lazor Kit – a Solana Smart Wallet solution with Passkey support
- Connect/disconnect Solana smart wallets with Passkey support
- Sign messages and transactions
- Use in any React project (Vite, Next.js, Create React App, etc.)
- Customizable UI components
- Works in browser environments with Buffer support
npm install @lazorkit/wallet
# or
yarn add @lazorkit/walletIf your project needs Buffer (for example, when decoding transactions), install the buffer package and polyfill it globally if your bundler does not do this automatically:
import { Buffer } from 'buffer';
window.Buffer = Buffer; // Polyfill global Buffer if neededMost modern bundlers (Vite, Webpack 5) will auto-polyfill Buffer if you install the
bufferpackage.
The main hook for interacting with the wallet:
import { useWallet } from '@lazorkt/wallet';
const {
isConnected, // boolean: wallet connection status
publicKey, // string | null: user's public key
connect, // () => Promise<void>: connect wallet
disconnect, // () => void: disconnect wallet
signMessage, // (message: Uint8Array) => Promise<Uint8Array>: sign a message
error, // string | null: error message if any
} = useWallet();A ready-to-use React component for wallet connection UI:
import { LazorConnect } from '@lazorkt/wallet';
<LazorConnect onConnect={publicKey => { console.log('Connected:', publicKey); }} />You can use and customize the button component via the as prop or pass your own component:
import { WalletButton } from '@lazorkit/wallet';
// Use a different HTML element
<WalletButton as="a" href="/custom">Connect Wallet</WalletButton>
// Or use your own React component
<WalletButton as={MyCustomButton} />import { LazorConnect, useWallet } from '@lazorkit/wallet';
function App() {
const { isConnected, publicKey, connect, disconnect } = useWallet();
return (
<div>
<LazorConnect onConnect={connect} />
{isConnected && <div>Public Key: {publicKey}</div>}
<button onClick={disconnect}>Disconnect</button>
</div>
);
}- If using Buffer in the browser, install
bufferand polyfill if needed.
MIT
